[C++] init.c/build_new wrongly implements new-expression

Alexandre Oliva oliva@dcc.unicamp.br
Mon May 31 21:06:00 GMT 1999


On May 25, 1999, Gabriel Dos_Reis <Gabriel.Dos_Reis@sophia.inria.fr> wrote:

> It unambigously states that the new-expression requests memory 
> *no less than the size of the object being created*.

But it doesn't state what should happen if the size of the object
being created doesn't fit in the std::size_t to be passed to
new-expression, therefore it's undefined behavior [defns.undefined].
Since anything at all can happen, throwing bad_alloc is an option, but
it is not mandated, and I'd find it quite strange to have bad_alloc
thrown even though my custom `operator new' was never called.

-- 
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