This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: 'throw' in new operator


Rafal Lukawski <rafal@dumb.iinf.polsl.gliwice.pl> writes:

> the following program causes 'Aborted (core dumped)':

And it is correct.  `new char[1024*1024]' calls `operator new[]', not
the `operator new' you define.  `operator new[]' is defined to call
`operator new', but it cannot propagate an `int', because it is
declared to throw only `std::bad_alloc'.  Thus, when `operator new[]'
tries to propagate the `int' you throw, the EH mechanism calls
`unexpected', that calls `terminate', that abort()s the program.

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]