new - bad_alloc or NULL

D

Dennis George

Hi all,

I was in the assumption that "new" by default throws an exception and
if you want "new" to return NULL you use "std::nothrow"....

So I like to know that whether my assumption is correct or not......

Following are some of the links that supports my argument.....
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=170
http://www.csci.csusb.edu/dick/c++std/cd2/expr.html#expr.new ---
Point 16

Following are some of the links that says the other story....
http://www.csci.csusb.edu/dick/c++std/cd2/expr.html#expr.new ---
Point 13
http://msdn.microsoft.com/library/d...en-us/vccore98/HTML/_langref_new_operator.asp

So can you tell me who is correct... basically I am confused by the
point-13 and point-16 of the standard.....
So what will I expect in the compilers I will be using????

Regards,
Dennis
 
J

John Carson

Dennis George said:
Hi all,

I was in the assumption that "new" by default throws an exception and
if you want "new" to return NULL you use "std::nothrow"....

So I like to know that whether my assumption is correct or not......

Following are some of the links that supports my argument.....
http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=170
http://www.csci.csusb.edu/dick/c++std/cd2/expr.html#expr.new ---
Point 16

Following are some of the links that says the other story....
http://www.csci.csusb.edu/dick/c++std/cd2/expr.html#expr.new ---
Point 13
http://msdn.microsoft.com/library/d...en-us/vccore98/HTML/_langref_new_operator.asp

So can you tell me who is correct... basically I am confused by the
point-13 and point-16 of the standard.....
So what will I expect in the compilers I will be using????

Regards,
Dennis

C++ was standardised in 1998. Your first link precedes it and your second
link describes the behaviour of VC++ 6.0 which also preceded the standard.
All pre-1998 documents (some in the next couple of years) are a waste of
time if you want to know what standard C++ requires.
 
D

Dennis George

So where can I find the latest c++ standard documented?
So this means that VC++ 6.0 works on a non-standard (or older
standard)...
 
G

Gavin Deane

Dennis said:
So where can I find the latest c++ standard documented?

If you go here
http://webstore.ansi.org/ansidocstore/default.asp
and search for 14882, the 2003 C++ standard appears to be available for
30 USD.
So this means that VC++ 6.0 works on a non-standard (or older
standard)...

There is no C++ standard older than 1998. VC++ 6.0 predates this so
does not conform to any standard because, at the time it was produced,
there was no standard.

Gavin Deane
 
D

Default User

Gavin Deane wrote:

There is no C++ standard older than 1998. VC++ 6.0 predates this so
does not conform to any standard because, at the time it was produced,
there was no standard.

This is not strictly true. VC++6, while it has some areas where it
fails to (correctly) implement the standard, is largely compliant. It's
not at all the same as using a pre-standard C++ compiler.




Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,235
Latest member
Top Crypto Podcasts_

Latest Threads

Top