Exceptions, 2.95 & 2.95.1, Sun Sparc & Linux (PC)

Sebastian Ritterbusch wct01@rz.uni-karlsruhe.de
Wed Sep 22 12:18:00 GMT 1999


Hi!

The following code compiles and runs fine on egcs-1.1.2 but only compiles 
on 2.95 and 2.95.1. I found this bug on a Sun Sparc with 2.95.1 and 2.95,
after I saw this on Linux (PC) with 2.95.1 as well I decided to tell you.

Catching D works fine, but catching B or A crashes the program after the
catch. (Bus Error, Segmentation fault, ...)

Just compile via "g++ bug.cpp -o bug", I hope you can reproduce it.

Bye, Sebastian!

--- bug.cpp
#include <string>
#include <iostream>

class A
{
   public:
      virtual int f() const throw() { return 1; }
   protected:
      std::string fkt;
};

class B : public virtual A
{
};

class C: public virtual A
{
};

class D: public virtual B, public virtual C
{
public:
      virtual int f() const throw() { return 2; }

};

int main(void)
{
   try{
      throw D();
   } 
   catch(const A & b)
   {
      std::cout << b.f() << endl;
   }
}
---



More information about the Gcc-bugs mailing list