[C++] init.c/build_new wrongly implements new-expression
Alexandre Oliva
oliva@dcc.unicamp.br
Mon May 24 21:38:00 GMT 1999
On May 24, 1999, Gabriel Dos_Reis <Gabriel.Dos_Reis@sophia.inria.fr> wrote:
> So that the following ends up with a segmentation fault instead of
> throwing a bad_alloc:
> double* p = new double[numeric_limits<size_t>::max()];
It is correct. It is not the allocation that fails, it's the size
calculation that overflows, thus producing undefined results.
--
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
{oliva,Alexandre.Oliva}@dcc.unicamp.br aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists
More information about the Gcc-bugs
mailing list