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

XMLWordPrintable

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

      MacOs 10.9.5, XCode 6.0.1 (6A317)

    • b34
    • x86
    • os_x
    • Not verified

        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;
        }

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

                Created:
                Updated:
                Resolved:

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