8058827: XCode 6.0 (Clang) warning "operator new' should not return a null pointer unless..."
authordrchase
Mon, 22 Sep 2014 14:19:11 -0400
changeset 26811 994a38f2afeb
parent 26810 ad491ed6cda8
child 26812 c2515f50cdb3
8058827: XCode 6.0 (Clang) warning "operator new' should not return a null pointer unless..." Summary: Rewrote the null pointer in a way that is not recognized by the compiler (the code is never executed). Reviewed-by: kvn
hotspot/src/share/vm/memory/allocation.cpp
--- a/hotspot/src/share/vm/memory/allocation.cpp	Sun Sep 21 16:13:39 2014 +0200
+++ b/hotspot/src/share/vm/memory/allocation.cpp	Mon Sep 22 14:19:11 2014 -0400
@@ -693,14 +693,16 @@
 // compilers and they should be upwards compatible with C++11/14. Therefore
 // PLEASE BE CAREFUL if you change the signature of the following operators!
 
+static void * zero = (void *) 0;
+
 void* operator new(size_t size) /* throw(std::bad_alloc) */ {
   fatal("Should not call global operator new");
-  return 0;
+  return zero;
 }
 
 void* operator new [](size_t size) /* throw(std::bad_alloc) */ {
   fatal("Should not call global operator new[]");
-  return 0;
+  return zero;
 }
 
 void* operator new(size_t size, const std::nothrow_t&  nothrow_constant) throw() {