This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to build_throw
>>>>> "Richard" == Richard Henderson <rth@redhat.com> writes:
> On Mon, Apr 23, 2001 at 12:42:28AM +0100, Jason Merrill wrote:
>> The C++ standard says that if an exception is thrown between the evaluation
>> of the expression to be thrown and it being caught, terminate() is called.
> Correct, but before the expression is completely evaluated, a new
> exception may be substituted. For instance,
> struct A
> {
> A () { throw 1; }
> A (const A&) { }
> };
> should free the exception object we allocated for "throw a" in main
> and propagate the "1".
When we're in A() we haven't allocated the exception object yet, so we
don't need to worry about that. This was deliberate:
/* Store the throw expression into a temp. This can be less
efficient than storing it into the allocated space directly, but
if we allocated the space first we would have to deal with
cleaning it up if evaluating this expression throws. */
Jason