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]

[Bug c++/13944] [3.3/3.4/3.5] exception in constructor of a class to be thrown is not caught


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-16 03:07 -------
I do not believe there is any ambiguity in the standard here.

This program should clearly through an exception of type "int" with the value
"1", and that exception should be caught in "main".

The problem here is that we have gotten too clever in build_throw; we try to
construct the object of type "A" directly into the exception object that will be
thrown.  That eliminates the separation between the evaluation of the operand
and the construction of the temporary that is required by the standard.  The
standard allows us to eliminate the temporary only if that does not change the
meaning of the program other than by changing what constructors/destructors are
called; in this case, it changes whether or not "terminate" is called.

The changes in build_throw are an attempt at an optimization, but that
optimization is not valid unless we can prove that no exceptions will be thrown.
 Optimizing this case doesn't seem very important to me, given that exceptions
are already assumed to be off the fast path.

Jason, you seem to have been the one who introduced the optimization.  

Would you please revert your changes, or, alternatively rebut my claims above?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at redhat dot com
         AssignedTo|unassigned at gcc dot gnu   |jason at redhat dot com
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13944


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