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]

-fno-rtti BUG Solaris/Linux


I posted this problem a few weeks back but got no reply. Maybe someone can
help me or advise me what I am doing wrong.

Background: I am writing a program that is linking w/ C++ libraries with
RTTI disabled (mainly because they are compiled with g++ 2.7.x.x where RTTI
is flakey). However, whenever I -fno-rtti and throw I get a SIGSEGV.

Compile the very simple program below as follows: "g++ -fno-rtti crash.cxx".
Run it and you will get a segmentation violation. Looking at the stack back
trace:

#0  0x14e50 in __is_pointer (p=0x15cd8)
#1  0x12954 in __cp_pop_exception (p=0x27670)
#2  0x118d8 in main ()

I built egcs-1.1.1 on Solaris 2.6, SunOS 5.5.1, Slackware Linux 3.2 w/
binutils 2.9.1. and always got the core dump. I did a:

cd /my/dir
../egcs-1.1.1/configure --prefix=/my/dir --with-gnu-as --with-gnu-ld
make CFLAGS='-O' LIBCFLAGS='-g -O2' LIBCXXFLAGS='-g -O2
-fno-implicit-templates'

According to the documentation you don't need RTTI to use exception
handling (see egcs-1.1.1/gcc/cp/gxxint.texi)

<SNIP>
"When -frtti is used, rtti is used to do exception object type checking,
when it isn't used, the encoded name for the type of the object being
thrown is used instead."
...
"Only exact type matching or reference matching of throw types works when
-fno-rtti is used.  Only works on a SPARC (like Suns) (both -mflat and
-mno-flat models work), SPARClite, Hitachi SH, i386, arm, rs6000,
PowerPC, Alpha, mips, VAX, m68k and z8k machines."
</SNIP>

This is about where the limit of my knowledge on the subject trails off but
I reckon the code should work without RTTI. I did have a look in
exception.cc and tinfo2.cc. Is __is_pointer still trying to do a
dynamic_cast when none of the typeinfo is there?

Any help would be greatly appreciated.

Thanks in advance,

James Bourne

// rtticrash.cxx
#include <iostream>

class CException
{
public:
   CException(void) { }
   ~CException(void) { }
};

int
main(int argc, char ** argv)
{
   try
   {
      throw CException();
   }
   catch (CException & e)
   {
      std::cerr << "I caught it!" << std::endl;
   }

   return 0;
}



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