Topic: placement new with null pointer value?
Author: anti_spam_email2003@yahoo.com (Me)
Date: Sat, 26 Jun 2004 06:16:33 +0000 (UTC) Raw View
Foo *f = ::new((void*)0) Foo();
Is that guaranteed by the standard to just do nothing (except assign f
to (Foo*)0 of course)?
5.3.4s13 implies this because this placement new (18.4.1.3) has an
empty throw() exception specification but I want to make sure because
I've heard nobody mention this before (and I searched google a bit
before I posted).
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: usenet@disemia.com (edA-qa mort-ora-y)
Date: Sun, 27 Jun 2004 07:40:50 +0000 (UTC) Raw View
Me wrote:
> Foo *f = ::new((void*)0) Foo();
> Is that guaranteed by the standard to just do nothing (except assign f
> to (Foo*)0 of course)?
Yes, according to the standard that is true. As you mentioned, 5.3.4
thus results in:
-the placement new allocation function returns null
-since it has a throw() clause the 0 is interpreted as a bad_alloc
-thus the initliazer is not called
-and the new operator returns 0
--
edA-qa mort-ora-y (Producer)
Trostlos Records <http://trostlos.org/>
"What suffering would man know if not for his own?"
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]