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 assume we are not talking about multithreading.

That's another issue.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


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