Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8058827

XCode 6.0 (Clang) warning "operator new' should not return a null pointer unless..."

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Environment:

      MacOs 10.9.5, XCode 6.0.1 (6A317)

    • Subcomponent:
    • Resolved In Build:
      b34
    • CPU:
      x86
    • OS:
      os_x
    • Verification:
      Not verified

      Backports

        Description

        New warning with official XCode 6.0 release, compiling fastdebug (and probably slowdebug as well):

        /Users/dr2chase/work/jdk9/hotspot/src/share/vm/memory/allocation.cpp:698:3: error: 'operator new' should not return a null pointer unless it is declared 'throw()' [-Werror,-Wnew-returns-null]
          return 0;
          ^

        Proposed fix:

        static void * zero = (void *) 0;

        void* operator new(size_t size) /* throw(std::bad_alloc) */ {
          fatal("Should not call global operator new");
          return zero;
        }

        void* operator new [](size_t size) /* throw(std::bad_alloc) */ {
          fatal("Should not call global operator new[]");
          return zero;
        }

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                drchase David Chase (Inactive)
                Reporter:
                drchase David Chase (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - 2 hours
                    2h
                    Remaining:
                    Remaining Estimate - 2 hours
                    2h
                    Logged:
                    Time Spent - Not Specified
                    Not Specified