Invalid exception unwind info with -fomit-frame-pointer

Andris Pavenis andris@stargate.astr.lu.lv
Sat Jun 19 12:04:00 GMT 1999


Hi!

In following example I'm getting crash when exception is thrown and command
line options for compiler is '-O2 -fomit-frame-pointer'. 

Tested with egcs-19990607 for i586-pc-linux-gnu
          with egcs-19990615 for i586-pc-msdosdjgpp
          earlier with egcs-1.1.2

Result doesn't change

Andris


------------------------  except.cc  ------------------------------------
/*  egcs-1.1.X and current gcc-2.95 prereleases generates wrong
    DWARF unwind info for exceptions handling:
	
	compile command:
	    gcc -O2 -fomit-frame-pointer except.cc -lstdc++ -o except
	    
	result crashes when rethrowing exception in x1a() when optimazation
	and -fomit-frame-pointer is requested. Without optimization or/and without 
        -fomit-frame-pointer there are no crashes
	
*/	

#include <iostream>
#include <string>


void x1 (void) throw (xx)
;
class xx {};

class test
  {
  public:
         string text;
         
         test (const char * x) : text(x)
           {
               cout << this << " test::test(\"" << text << "\")\n";
           }
           
         ~test ()
           {
               cout << this << " test::~test()\n";
	       cout << "        \"" << text << "\"\n";
           }
  };


void  touch ( test & x ); /* Let's fool gcc to think this object is really used */


void x1a (void)
  {
     test w3 ("void x1a (void)");
     touch (w3);
     x1 ();
  }

int main (void)
{
   try { x1a(); } catch (xx w) { cout << "catched from x1a()\n"; }
   return 0;
}


void  touch ( test & )
{
}



void x1 (void) throw (xx)
  {
     test w1 ("void x1 (void) throw (xx)");
     touch (w1);
     xx a;
     throw(a);
  }


----------------------------  Output  -----------------------------------------

0xbffff910 test::test("void x1a (void)")
0xbffff868 test::test("void x1 (void) throw (xx)")
0xbffff868 test::~test()
        "void x1 (void) throw (xx)"
0xbffff900 test::~test()
        various garbage as object address is wrong

 	   


More information about the Gcc-bugs mailing list