http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47774
--- Comment #7 from Adam Butcher <dev.lists at jessamine dot co.uk> 2011-03-01 15:34:40 UTC --- (In reply to comment #6) > Yep, this is fixed too. > > *** This bug has been marked as a duplicate of bug 46472 *** > The attached program demonstrated instances of the bug with various member types. It still fails on two cases when using array members. I don't think they are errors. Running sh constexpr-ctor-templ.cpp with 4.6.0 20110301 now yields the following (output compressed for legibility [snip] = -c constexpr-ctor-templ.cpp -std=c++0x). -------------------------------------------- + g++ [snip] -DPLAIN_T -DUSE_SYNTHESIZED_X_CTOR + g++ [snip] -DPLAIN_T -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR + g++ [snip] -DPLAIN_T -DGIVE_X_EXPLICIT_NONCONST_CTOR + g++ [snip] -DPLAIN_T_ARRAY -DUSE_SYNTHESIZED_X_CTOR -------------------------------------------- + g++ [snip] -DPLAIN_T_ARRAY -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T = ncbool]’: constexpr-ctor-templ.cpp:148:14: instantiated from here constexpr-ctor-templ.cpp:103:24: error: ‘ncbool::ncbool(bool)’ is not ‘constexpr’ -------------------------------------------- + g++ [snip] -DPLAIN_T_ARRAY -DGIVE_X_EXPLICIT_NONCONST_CTOR + g++ [snip] -DFLAG_T -DUSE_SYNTHESIZED_X_CTOR + g++ [snip] -DFLAG_T -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR + g++ [snip] -DFLAG_T -DGIVE_X_EXPLICIT_NONCONST_CTOR + g++ [snip] -DFLAG_T_ARRAY -DUSE_SYNTHESIZED_X_CTOR -------------------------------------------- + g++ [snip] -DFLAG_T_ARRAY -DGIVE_X_EXPLICIT_CONSTEXPR_CTOR constexpr-ctor-templ.cpp: In constructor ‘constexpr X<T>::X() [with T = ncbool]’: constexpr-ctor-templ.cpp:148:14: instantiated from here constexpr-ctor-templ.cpp:103:24: error: ‘constexpr flag<BoolType>::flag(bool) [with BoolType = ncbool]’ is not ‘constexpr’ -------------------------------------------- + g++ [snip] -DFLAG_T_ARRAY -DGIVE_X_EXPLICIT_NONCONST_CTOR -------------------------------------------- Failed 2 The failing invocations occur when an array of a type that cannot be used to construct compile-time constants is used as a member of X when X is given a constexpr constructor. With the new compiler, the result comments become: --- constexpr-ctor-templ.cpp 2011-03-01 14:57:22.000000000 +0000 +++ constexpr-ctor-templ.cpp 2011-03-01 14:58:55.000000000 +0000 @@ -113,11 +113,11 @@ #if PLAIN_T T mem; // doesn't fail in any mode #elif FLAG_T - flag<T> mem; // fails only with synthesized ctor + flag<T> mem; // doesn't fail in any mode now #elif PLAIN_T_ARRAY T mem[7]; // fails only with GIVE_X_EXPLICIT_CONSTEXPR_CTOR #elif FLAG_T_ARRAY - flag<T> mem[7]; // fails unless GIVE_X_EXPLICIT_NONCONST_CTOR + flag<T> mem[7]; // fails only with GIVE_X_EXPLICIT_CONSTEXPR_CTOR #endif }; I.e. The plain array member still fails as it did before and the flag<T> array member now fails in the same way as the plain array member (which is a change from how it failed before). Since the failures are now purely array related, a simplified program with no macro configuration that reproduces the problem is: struct ncbool { ncbool(bool b = false) : b(b) {} bool b; }; template <typename BoolType> struct flag { constexpr flag(BoolType b = false) : b(b) {} BoolType b; }; template <typename T> struct array { constexpr array() : mem() {} T mem[7]; }; int main(int argc, char**) { // The following are not declared constexpr // so shouldn't result in constexpr errors. array<ncbool> array_of_plain_ncbool; array<flag<ncbool>> array_of_flag_ncbool; }