public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* 'new' behavior when malloc() fails
@ 2001-02-26 23:19 David Whedon
  2001-02-27 14:20 ` Alexandre Oliva
  0 siblings, 1 reply; 2+ messages in thread
From: David Whedon @ 2001-02-26 23:19 UTC (permalink / raw)
  To: gcc-help

I'm using the gnu c++ compiler.  The question is related to the 'new' operator.

Sometimes the calls to __builtin_new (g++ generates these calls) return NULL
because there is no memory to be had (I'm working on an embedded system).
Unfortunately, the code that g++ generates doesn't check the return value of
__builtin_new before calling the class constructor.  

I can only assume that this is by design.

Calling the constructor when the system was unable to allocate memory for the
class is bad?  What am I missing?

This may be a c++ specific question, and may not be gcc-specific, if so I'm 
happy to ask on a c++ list.

Thank you,

David Whedon

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: 'new' behavior when malloc() fails
  2001-02-26 23:19 'new' behavior when malloc() fails David Whedon
@ 2001-02-27 14:20 ` Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2001-02-27 14:20 UTC (permalink / raw)
  To: David Whedon; +Cc: gcc-help

On Feb 27, 2001, David Whedon <dwhedon@gordian.com> wrote:

> Sometimes the calls to __builtin_new (g++ generates these calls)
> return NULL

IIRC, only old releases of GCC do.  Newer releases have the behavior
dictated by the C++ Standard, which is to throw an exception.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-02-27 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-26 23:19 'new' behavior when malloc() fails David Whedon
2001-02-27 14:20 ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).