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]
Other format: [Raw text]

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


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