g++ 2.95.2 bug report

Jay Baus baus@roguewave.com
Fri Dec 31 20:54:00 GMT 1999


Hello,

The following is a bug report for the g++ 2.95.2 compiler.  

There appears to be a problem with inheritance heirarchies and exceptions.
The code example given below drops core.   However, using the EDG 2.42
compiler, the example compiles and runs without incident.

Note: there are three modifications that (independently) stop the core
dumping.
1. removing the member variable from A.
2. reversing the order of inheritance in B, i.e. "struct B : A, X"
3. catching a reference to the derived class B instead of the base class A.

Here is the code:



struct X { };

struct A {
    int i;

    virtual ~A () { }
};


struct B: X, A { };


int main ()
{
    try {
        throw B ();
    }
    catch (A &) {
    }
}


And here are the compilation details:

$  g++ -v -c testit.cpp

Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cpp -lang-c++ -v -D__GNUC__=2
-D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__
-Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
-Asystem(posix) -D__EXCEPTIONS -Acpu(i386) -Amachine(i386) -Di386 -D__i386
-D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro
-D__pentiumpro__ testit.cpp /tmp/ccNRIjcd.ii
GNU CPP version 2.95.2 19991024 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3
 /usr/local/include
 
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../i686-pc-linux-gnu/incl
ude
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/cc1plus /tmp/ccNRIjcd.ii -quiet
-dumpbase testit.cc -version -o /tmp/cccYpFMf.s
GNU C++ version 2.95.2 19991024 (release) (i686-pc-linux-gnu) compiled by
GNU C version 2.95.2 19991024 (release).
 as -V -Qy -o testit.o /tmp/cccYpFMf.s
GNU assembler version 2.9.1 (i386-redhat-linux), using BFD version
2.9.1.0.23


$ g++  testit.o -v -o testit 

Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/collect2 -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 -o testit /usr/lib/crt1.o /usr/lib/crti.o
/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/crtbegin.o
-L/usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2 testit.o -lstdc++ -lm -lgcc -lc
-lgcc /usr/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/crtend.o /usr/lib/crtn.o


$ ./testit

Memory fault (core dumped) 




Thanks,
Jay Baus
====================
Jay M. Baus, Software Engineer
Rogue Wave Software, Inc.   
baus@roguewave.com  
(303) 545-3197 
====================



More information about the Gcc-bugs mailing list