C++ operator new when out of heap.

Nick.SIMON at syntegra.bt.co.uk Nick.SIMON at syntegra.bt.co.uk
Wed Aug 30 06:17:53 UTC 2000


C++ Programming Language, 3rd edition bu Bjarne Stroustrup (and he should
know) says "What happens when new can find no store to allocate? By default
the operator throws a bad_alloc exception." (section 6.2.6.2).

The 1996 draft standard at http://anubis.dkuug.dk/jtc1/sc22/open/n2356/ or
at ftp://research.att.com/dist/c++std/WP/CD2/body.pdf says: "If   a nothrow
allocation function (_lib.support.dynamic_) fails to allocate storage, it
shall return a null pointer.  Any other allocation function that fails to
allocate storage shall only indicate failure by throwing an exception of
class std::bad_alloc (_lib.bad.alloc_) or a class derived from
std::bad_alloc." in section 3.7.3.1  Allocation functions
[basic.stc.dynamic.allocation].

I'm too mean to pay for the current standard!


My RTEMS Panics on out-of-heap anyway.  Is this a build option?


-- Nick Simon 

> -----Original Message-----
> From: angelo [mailto:angelo at hunterlink.net.au]
> Sent: 30 August 2000 00:39
> To: Nick.SIMON at syntegra.bt.co.uk
> Cc: rtems-users at oarcorp.com
> Subject: Re: C++ operator new when out of heap.
> 
> 
> Do you have a reference for this?? I thought the standard was 
> completed in
> 1988.
> 
> Nick.SIMON at syntegra.bt.co.uk wrote:
> 
> > The C++ spec now says that 'new' never returns null, but if 
> out of heap
> > throws an exception (a C++ exception that is).
> >
> > Does anyone know if this is the case with RTEMS tools & 
> libraries, or is
> > null returned as per the old standard?  I'm using 4.5.0 
> beta 3 (soon to be
> > beta 3a).
> >
> > TIA,
> >
> > -- Nick Simon
> >
> > I used to think I was uncertain, but now I'm not sure.
> 
> --
> Angelo Fraietta
> 
> PO Box 859
> Hamilton NSW 2303
> 
> Home Page
> 
> http://users.hunterlink.net.au/~maaaf/
> 
> There are those who seek knowledge for the sake of knowledge - that is
> CURIOSITY
> There are those who seek knowledge to be known by others - 
> that is VANITY
> There are those who seek knowledge in order to serve - that is LOVE
>     Bernard of Clairvaux (1090 - 1153)
> 
> 
> 



More information about the users mailing list