Bug in egcs 1.1 -fno-rtti + exception = segfault

Marco Manfai Yu yumf@ultimatech.com
Fri Oct 16 12:13:00 GMT 1998


Hi,

This may be obvious but running the following code results in a seg
fault. Basically the code throws one of the standard exceptions. When
compiled with -fno-rtti the code segfaults in __is_pointer().
This is compiled with egcs 1.1 on a glibc2 machine
(i686-pc-linux-gnu).

Here's the code.

/**-*-c++-*-*/
#include <iostream.h>
#include <stdexcept>

struct A {
    static void foo (void) {
	throw overflow_error("X");
    }
};

int
main (int argc, char **argv)
{
    try {
	A::foo();
    } catch (overflow_error p) {
	cout << "Caught " << p.what() << endl;
    }
}

Compile this with 

% g++ -v -fno-rtti -g -o foo foo.cc

Then run in gdb 4.17.

% gdb foo
GNU gdb 4.17
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-pc-linux-gnu"...
(gdb) r
Starting program: /home2/yumf/tmp/foo 
Caught X

Program received signal SIGSEGV, Segmentation fault.
0x4004047f in __is_pointer (p=0x804ad2f)
(gdb) bt
#0  0x4004047f in __is_pointer (p=0x804ad2f)
#1  0x4003e48c in __cp_pop_exception (p=0x804cbe8)
#2  0x8049e05 in main (argc=1, argv=0xbffff7cc) at foo.cc:17
(gdb) 

--------------------------------------------------------------------------
This code used to work under egcs-1.0.3a.


Marco Yu
yumf@ultimatech.com



More information about the Gcc-bugs mailing list