This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: EH in egcs
- To: oliva at dcc dot unicamp dot br (Alexandre Oliva)
- Subject: Re: EH in egcs
- From: hjl at lucon dot org (H.J. Lu)
- Date: Sun, 26 Oct 1997 18:01:04 -0800 (PST)
- Cc: jason at cygnus dot com, egcs at cygnus dot com
>
> 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)