This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9433: [3.2/3.3/3.4 regression] SegFault in dynamic_cast
- From: bangerth at dealii dot org
- To: gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, yanliu at ca dot ibm dot com
- Date: 24 Jan 2003 15:22:42 -0000
- Subject: Re: c++/9433: [3.2/3.3/3.4 regression] SegFault in dynamic_cast
- Reply-to: bangerth at dealii dot org, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, nobody at gcc dot gnu dot org, yanliu at ca dot ibm dot com, gcc-gnats at gcc dot gnu dot org
Old Synopsis: memory fault
New Synopsis: [3.2/3.3/3.4 regression] SegFault in dynamic_cast
State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Jan 24 15:22:42 2003
State-Changed-Why:
Confirmed (one x86 linux). It used to work with 2.95, but is broken in
3.2, 3.3, and 3.4 branches/CVS. The following slightly
simplified testcase shows the same behavior (the class
hierarchy is an exercise in applied graph theory :-)
-------------------------------
struct A { virtual ~A() {}; };
struct B {};
struct C : A, B {};
struct D : C {};
struct E : C {};
struct F : protected D, E {};
struct H : virtual F {};
struct I : H {};
struct J : H {};
struct K : I, J {};
struct M : K {};
struct N : M {};
struct O : M {};
struct P : N, O {};
int main() {
P obj;
A* a1 = (D*)&obj;
dynamic_cast<H*>(a1);
}
-------------------------------
The Segfault happens in the runtime support libs (with 3.4):
(gdb) bt
#0 0x4006c7a2 in __cxxabiv1::__vmi_class_type_info::__do_find_public_src(int, void const*, __cxxabiv1::__class_type_info const*, void const*) const (
this=0x804a4a0, src2dst=-1, obj_ptr=0x0, src_type=0x804a488,
src_ptr=0xbffff184)
at ../../../../gcc-3.4-CVS/libstdc++-v3/libsupc++/tinfo.cc:122
#1 0x4006cd0d in __cxxabiv1::__vmi_class_type_info::__do_dyncast(int, __cxxabiv1::__class_type_info::__sub_kind, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info const*, void const*, __cxxabiv1::__class_type_info::__dyncast_result&) const (this=0x804ab60, src2dst=-1,
access_path=__contained_public, dst_type=0x804a4a0, obj_ptr=0xbffff174,
src_type=0x804a488, src_ptr=0xbffff184, result=@0xbffff120)
at ../../../../gcc-3.4-CVS/libstdc++-v3/libsupc++/tinfo.cc:264
#2 0x4006d0c3 in __dynamic_cast (src_ptr=0xbffff184, src_type=0x804a488,
dst_type=0x804a4a0, src2dst=-1)
at ../../../../gcc-3.4-CVS/libstdc++-v3/libsupc++/tinfo.cc:712
#3 0x08048703 in main () at x.cc:19
W.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9433