Bug 51612 - [c++0x] [4.6/4.7 Regression] ICE with constexpr constructor and virtual base class
Summary: [c++0x] [4.6/4.7 Regression] ICE with constexpr constructor and virtual base ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Paolo Carlini
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2011-12-18 20:54 UTC by Volker Reichelt
Modified: 2025-01-03 22:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-12-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2011-12-18 20:54:44 UTC
The following valid code snippet triggers an ICE on trunk:

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

struct B : virtual A
{
  constexpr B() {}
};
========================

bug.cc: In constructor 'constexpr B::B()':
bug.cc:5:18: internal compiler error: in build_data_member_initialization, at cp/semantics.c:5781
Please submit a full bug report, [etc.]
Comment 1 Jason Merrill 2011-12-18 22:27:30 UTC
This is not valid code; a class with virtual bases cannot have a constexpr constructor.
Comment 2 paolo@gcc.gnu.org 2011-12-20 10:38:48 UTC
Author: paolo
Date: Tue Dec 20 10:38:44 2011
New Revision: 182526

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182526
Log:
/cp
2011-12-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51612
	* semantics.c (is_valid_constexpr_fn): In case of constexpr
	constructors also check for virtual base classes.

/testsuite
2011-12-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51612
	* g++.dg/cpp0x/constexpr-ice4.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ice4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Paolo Carlini 2011-12-20 10:40:43 UTC
Fixed for 4.7.0.