changeset 26811:994a38f2afeb

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
author drchase
date Mon, 22 Sep 2014 14:19:11 -0400
parents ad491ed6cda8
children c2515f50cdb3
files hotspot/src/share/vm/memory/allocation.cpp
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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() {