gcc 3.0 C++ exception run-time crash on SPARC with -O2

Amaury Darsch amaury@ethernix.org
Sat Jul 14 17:57:00 GMT 2001


Folks, 

Here is a small test case that result in a run-time crash (SIGSEV)
when using GCC 3.0, sparc architecture, optimized code.

a) configuration
   GCC 3.0 / SPARC / SOLARIS 8 / Thread model posix

b) to reproduce
   g++ -Wall -O2 -o bug bug.cpp

d) comments
   The example runs well when compiling in debug or with -O3. Note that
   if the Object destructor is NOT marked virtual, the program will
   run fine, even with O2. No include file is needed to reproduce.
	
c) example

   class Object {
   public:
              Object (void);
     virtual ~Object (void);
   };

   // create a new object
   Object::Object (void) {
   }

   // destroy this object
   Object::~Object (void) {
   }

   // this function throw the object
   static void lance (void) {
     throw Object ();
   }

   int main (int, char**) {   
     // try to catch the object
     try {
       lance ();
     } catch (...) {
       return 0;
     }
     return 1;
   }



More information about the Gcc-bugs mailing list