9629 – [3.2/3.3/3.4 regression] virtual inheritance segfault (original) (raw)
Hi!
The following minimal testcase compiles and runs with gcc-2.95 and compiles and crashes with gcc-3.2.2. I am not sure whether it is a bug in the testcase or a bug in the compiler, but in any case I would appreciate hearing whats the problem with the testcase. Thanks.
Cu... StefanRelease: gcc-3.2.2
Environment: Debian unstable on i386
Comment 1 Wolfgang Bangerth 2003-02-14 20:46:18 UTC
State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed. Here's a very slightly reduced testcase: -------------------------- struct A { };
struct B {
B(A *) {}
};
struct C : virtual public A, public B {
C() : B(this) {}
};
struct D : virtual public C {};
main() {
new D();
}
------------------------
Executing this program segfaults with 3.2.2, 3.3, and 3.4.
So it is a regression, assuming the code is legal.
The problem is in casting this to A* in the constructor
C::C. It's trying to cast to a virtual base, and it seems
to me that this information is not available at the time
we get to C::C, which then causes the segfault. But that's
just a wild guess.
W.Comment 2 Nathan Sidwell 2003-02-21 16:08:06 UTC
Responsible-Changed-From-To: unassigned->nathan Responsible-Changed-Why: fixing
Comment 5 Nathan Sidwell 2003-03-17 11:52:48 UTC
State-Changed-From-To: analyzed->closed State-Changed-Why: fixed on HEAD and 3.3 2003-03-16 Nathan Sidwell <nathan@codesourcery.com>
[PR c++/9629](show%5Fbug.cgi?id=9629 "RESOLVED FIXED - [3.2/3.3/3.4 regression] virtual inheritance segfault")
* cp-tree.h (struct language_function): Add in_base_initializer.
(in_base_initializer): define it.
(expand_member_init): Remove INIT param.
* init.c (expand_member_init): Remove INIT param, return the member.
(emit_mem_initializers): Set in_base_initializer.
* class.c (build_base_path): Check in_base_initializer.
* parser.c (cp_parser_mem_initializer): Set in_base_initializer.
* pt.c (tsubst_initializer_list): Likewise.