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]

c++/7991: Exception in destructor gets caught twice


>Number:         7991
>Category:       c++
>Synopsis:       Exception in destructor gets caught twice
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 20 13:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ryan Mack
>Release:        gcc-3.2
>Organization:
>Environment:
RH 7.3, cygwin
>Description:
It seems that even though the exception is caught in the destructor, it gets caught again when exiting the catch block.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="foo.cpp"
Content-Disposition: inline; filename="foo.cpp"

#include <iostream>

struct A {
  ~A()
  {
    throw 1;
  }
};

struct B {
  A a;

  ~B()
  try {
  } catch (int i) {
    std::cerr << "caught exception in ~B: " << i << std::endl;
  }
};

int main(int argc, char** argv)
{
  try {
    B b;
  } catch (int i) {
    std::cerr << "caught exception in main: " << i << std::endl;
  }
  return 0;
}


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