This is the mail archive of the gcc@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]

Sun4 RTTI SIGSEGV Headache


All,

uname -a: SunOS hertz 5.5.1 Generic sun4m sparc SUNW,SPARCstation-5
g++ -v: gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release) + binutils
2.9.1

This sample code below works fine on Linux 2.0.36 (egcs-2.90.29) and NT
VC6SP2 but core dumps on the Sparc when I: g++ -O3 -fno-rtti main.cxx.

I don't know what to do next?! Is this a buggy egcs lib? Solaris lib? I
have RTFM'ed and FAQ'ed but have come up with zilch. Any suggestions why
this might be occuring or how to fix it?

Interestingly the Linux a.out is 7Kb but the Solaris is 410Kb! Something is
getting statically linked that I don't know about?

Many thanks in advance,

James Bourne

------------------------------------------------------------------
gdb stack backtrace yields:

Program terminated with signal 11, Segmentation Fault.
Reading symbols from /usr/lib/libm.so.1...done.
Reading symbols from /usr/lib/libc.so.1...done.
Reading symbols from /usr/lib/libdl.so.1...done.
#0  0x215b0 in __is_pointer (p=0x22580)
(gdb) bt
#0  0x215b0 in __is_pointer (p=0x22580)
#1  0x1ee44 in __cp_pop_exception (p=0x36bf8)
#2  0x11eb8 in main (argc=224248, argv=0xeffffcbc) at main.cxx:24

//------------------------------------------------------------------
// Source for CException.h
class CException
{
public:
   CException(void) {}
   virtual ~CException(void) {}
};

class CAnotherException: public CException
{
};
// End source CException.h

//------------------------------------------------------------------
// Source of main.cxx
#include <iostream>
#include <new>
#include "CException.h"

class SomeClass
{
public:
   SomeClass(void) { throw CAnotherException(); }
   ~SomeClass(void) { }
};

int
main(int argc, char ** argv)
{
   SomeClass * sc = NULL;
   try
   {
      try
      {
         sc = ::new SomeClass();
      }
      catch (CAnotherException & e)
      {
         std::cerr << "I caught it!" << std::endl;
      }
      ::delete sc;
   }
   catch (CException & e)
   {
      std::cerr << "I caught something else" << std::endl;
   }
   catch (bad_alloc & e)
   {
      std::cerr << "Bad memory allocation" << std::endl;
   }

   return 0;
}
// End main.cxx




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