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]

Exception handling bug




Hello,
     We found a bug in the exception handling of the gcc-2.95.2. If a
exception is throw in a constructor of an derived class,
the destructor of the base class should be called. Instead the constructor
is called twice and the program crashes. This only happens with the
setjmp/longjmp method. I debug it and found out the following:

If compiled without optimisation everything works fine. Turning on
optimisation throws code away in the flow optimisation of the gcc at the
point after the setjmp is issued. The (pseudo) code before flow looks like
this:

     setjmp (label exception_label)
     branch normal_flow:
exception_label:
     ...
     branch to destructor of base class (inlined)

normal_flow:
     constructor ...

after flow it looks like this:

     setjmp (label normal_flow)
normal_flow:
     constructor ...

It looks like the flow optimisation thinks, the basic block between
exception_label and normal_flow is not needed.

I append a example:


compile with : "g++ -fsjlj-exceptions -O2 exc.C"  on Intel/linux system
with g++ 2.95.2.

     Hartmut Penner
     Linux for S/390 development

P.S
     Everything works fine with dwarf2 exception handling used on Intel,
but we use currently sjlj on Linux for S/390

     gcc-2.96 will also crash, but a other point.










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