This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: 'throw' in new operator
- To: Rafal Lukawski <rafal at dumb dot iinf dot polsl dot gliwice dot pl>
- Subject: Re: 'throw' in new operator
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 13 Jun 1998 08:38:36 -0300
- Cc: egcs-bugs at cygnus dot com
- References: <Pine.LNX.3.96.980613115711.434A-100000@rafal.home>
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