This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/19476] Missed null checking elimination with new
- From: "sabre at nondot dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Nov 2005 02:13:50 -0000
- Subject: [Bug c++/19476] Missed null checking elimination with new
- References: <bug-19476-6528@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from sabre at nondot dot org 2005-11-13 02:13 -------
> Yes because the normal operator new guarante not to return NULL by the C++
> standard.
Sure.
> And if it returns a NULL that is undefined behavior, it should be
> throwing an exception when memory could not be allocated (there is a nonthrow
> version which can and will return NULL).
Sure, fine, but you need not be calling the default/normal operator new. I can
define an overload for operator new in a different translation unit, or even by
dynamically loading a library with a different one. This is similar to
replacing malloc. AFAICT, the C++ std does not say that the replacement
operator new may not return null.
-Chris
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19476