Bug 27952 - [4.1 Regression] ICE with invalid virtual inheritance
Summary: [4.1 Regression] ICE with invalid virtual inheritance
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P4 minor
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks:
 
Reported: 2006-06-08 10:35 UTC by Volker Reichelt
Modified: 2008-07-04 15:35 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3 3.2.3 4.2.0
Known to fail: 4.0.4 4.1.0 4.1.3
Last reconfirmed: 2006-10-17 18:15:01


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2006-06-08 10:35:30 UTC
The following testcase with invalid virtual inheritance ICEs since GCC 4.0.0:

==================================
struct A
{
    virtual ~A() {}
};

struct B : A, virtual A {};

struct C : A, B {};

C c;
==================================

bug.cc:6: error: duplicate base type 'A' invalid
bug.cc:8: warning: direct base 'A' inaccessible in 'C' due to ambiguity
bug.cc: In destructor 'virtual C::~C()':
bug.cc:8: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]

A more reduced version crashes since GCC 4.1.0:

==================================
struct A {};

struct B : A, virtual A {};

struct C : B {};
==================================

bug.cc:7: error: duplicate base type 'A' invalid
bug.cc:9: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]
Comment 1 patchapp@dberlin.org 2006-06-10 14:10:14 UTC
Subject: Bug number PR c++/27952

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00536.html
Comment 2 Andrew Pinski 2006-09-03 06:30:03 UTC
Confirmed.
Comment 3 patchapp@dberlin.org 2006-10-17 18:37:03 UTC
Subject: Bug number PR c++/27952

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00862.html
Comment 4 patchapp@dberlin.org 2006-10-17 23:01:04 UTC
Subject: Bug number PR c++/27952

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-10/msg00878.html
Comment 5 Lee Millward 2006-10-17 23:22:25 UTC
Subject: Bug 27952

Author: lmillward
Date: Tue Oct 17 23:22:14 2006
New Revision: 117839

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117839
Log:
        PR c++/27952
        * cp-tree.h (xref_basetypes): Return bool instead of void.
        * decl.c (xref_basetypes): Adjust definition. Return false
        if the class bases are invalid.
        * parser.c (cp_parser_class_head): Check the return value
        from xref_basetypes.

        * g++.dg/inherit/virtual1.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/inherit/virtual1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Lee Millward 2006-10-17 23:23:04 UTC
Fixed on mainline.
Comment 7 Gabriel Dos Reis 2007-02-03 17:35:40 UTC
Won't fix in GCC-4.0.x.  Adjusting milestone.
Comment 8 Joseph S. Myers 2008-07-04 15:35:05 UTC
Closing 4.1 branch.