Bug 51526 - [C++11][constexpr] constexpr delegating constructor should be accepted
Summary: [C++11][constexpr] constexpr delegating constructor should be accepted
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: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2011-12-13 08:41 UTC by Daniel Krügler
Modified: 2011-12-19 21:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-12-13 08:41:44 UTC
gcc 4.7.0 20111210 (experimental) rejects the following program by producing an ICE:

//--------
struct S {
  int i;
  constexpr S(int i) : i(i) {}
  constexpr S() : S(42) {}
};

constexpr S s{};
//--------

"
main.cpp||In constructor 'constexpr S::S()':|
main.cpp|4|internal compiler error: in build_data_member_initialization, at cp/semantics.c:5777
"

The code should be accepted, it seems that S::S() satisfies the criteria for a constexpr constructor as of 7.1.5.
Comment 1 Jason Merrill 2011-12-19 21:06:48 UTC
Author: jason
Date: Mon Dec 19 21:06:44 2011
New Revision: 182499

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182499
Log:
	PR c++/51526
	* semantics.c (build_data_member_initialization): Handle
	delegating constructor.
	(build_constexpr_constructor_member_initializers): Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-delegating.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-12-19 21:07:59 UTC
Fixed.