Created attachment 29215 [details] C++11 metaprogramming experiment Enclosed code fails to compile, but should. Tested with: g++-mp-4.7 (MacPorts gcc47 4.7.2_2) 4.7.2 g++-mp-4.8 (MacPorts gcc48 4.8-20130113_0) 4.8.0 20130113 (experimental) Compiled via: g++-mp-4.7 -O3 -std=c++0x main.cc g++-mp-4.8 -O3 -std=c++0x main.cc Use of expression true_type{} as template argument corresponding to bool template parameter produces diagnostic: 'constexpr integral_constant<T, v>::operator T() const [with T = bool; T v = true]' used before its definition [The syntax variant true_type() [note parentheses instead of braces as shown above] is correctly diagnosed, applying 14.3/2. This variant, as well as a C++03-style variant, are present but commented out in the attachment; I left them for possible additional experimentation.] Using braces should force interpretation as an expression, not a type. That expression should result in a default-constructed temporary object of the named type; that type, defined earlier in the source, has a conversion operator defined inline. However, the compiler claims that the operator's definition is not yet defined at the point of (implicit) use.
Author: jason Date: Thu Nov 20 03:25:26 2014 New Revision: 217823 URL: https://gcc.gnu.org/viewcvs?rev=217823&root=gcc&view=rev Log: PR c++/56041 * cp-tree.h (struct processing_template_decl_sentinel): New. * pt.c (instantiate_non_dependent_expr_internal): Split out from... (instantiate_non_dependent_expr_sfinae): Here. (convert_nontype_argument): Use them. * constexpr.c (fold_non_dependent_expr): Use them. Added: trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-conv1.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/pt.c
Fixed for GCC 5.