JDK-8058827 : XCode 6.0 (Clang) warning "operator new' should not return a null pointer unless..."
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2014-09-19
  • Updated: 2015-06-03
  • Resolved: 2014-09-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b34Fixed
Related Reports
Relates :  
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;
}