Hmmm. After hitting Send, I looked up set_new_handler() in the library
reference where it says "If you have not registered a new-handler function,
the default behavior is for the new operator to return NULL."

Is that in conflict with the Language Reference as quoted below, or am I
reading it wrong?

Also non-XPLINK, FWIW.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On
Behalf Of Charles Mills
Sent: Wednesday, January 21, 2015 5:29 PM
To: [email protected]
Subject: What am I missing about C++ new[] failure?

I have a C++ program in which I am trying to allocate an unreasonably-large
character array with new[]. I know it's unreasonably large - I'm a developer
testing something. It's 6.3MB -- not ridiculous, but in excess of the memory
available (apparently).

It appears to me that new is simply returning a NULL pointer, with no error
indication. That seems inconsistent with the C++ manual which says "If you
do not specify your own set_new_handler() function, new throws an exception
of type std::bad_alloc." I have an exception handler that is known to work
generally and it is not getting called. I do not call set_new_handler().

Am I missing something? Do others know that new generally fails as
documented?

z/OS V1R13. POSIX(ON).

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to