This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Exception allocation bug?
- From: Mike Harrold <mharrold at cas dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 5 Jul 2003 13:42:50 -0400 (EDT)
- Subject: Exception allocation bug?
Hi,
I don't know if this is a bug or a feature, but I am wondering why
the following code:
throw MyException();
results in the following:
MyException is constructed on the stack using default ctor.
__cxa_allocate_exception is called
A second MyException is constructed using the memory returned by
__cxa_allocate_exception, using MyException's copy ctor.
The first MyException is destroyed.
Couldn't this be optimised to:
__cxa_allocate_exception is called
MyException is constructed using the memory returned by
__cxa_allocate_exception, using MyExceptions' default ctor.
Thanks,
/Mike