egcs-1.1a: new don't not throw bad_alloc

Alexandre Oliva oliva@dcc.unicamp.br
Fri Sep 11 17:54:00 GMT 1998


Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de> writes:

> I tested the behaviour of 'new' again.
> If the size of the array is smaller then INT_MAX-11 (?),
> 'new' does throw bad_alloc.
> If it's INT_MAX-10 or more 'new' does not throw.

As I have already told you, the problem is not in `new', it is in
malloc(), that returns non-null when presented such a large request.
Just set a breakpoint in malloc(), check that the argument passed to
it is what you expect, then note that it returns a non-null value,
probably a pointer to a just-allocated memory region, but not as large 
as requested. :-(

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc mailing list