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

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • 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;
        }

              drchase David Chase (Inactive)
              drchase 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