This is the mail archive of the gcc@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]

Re: EH in egcs


> 
> H J Lu writes:
> 
> > How come there are multiple uncaught exceptions active at the
> > same time?
> 
> The following code fragment introduces two active uncaught exceptions.
> The `throw 1' expression causes the bar object to be destructed.
> While its destructor is being run, another exception is thrown.  If
> this exception were not caught, terminate would have been called.
> Anyway, there can be more than one pending exception, as long as they
> do not propagate outside the destructor called by the stack-unwinding
> mechanism.
> 
> struct foo {
>   ~foo() {
>     try { throw 2; }
>     catch(int) {}
>   }
> };
> main() {
>   try { foo bar; throw 1; }
>   catch(int) {}
> }
> 

I guess it depends on how you implement it. I can see

1. before throw 1
2. call bar.~foo ()
3. throw 2
4. catch 2
5. throw 1
6. catch 1

In this case, "throw 1" just makes bar out of scope.


-- 
H.J. Lu (hjl@gnu.ai.mit.edu)


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