Hi,
in this regression (Jakub figured out that it started with r72165) we
ICE during error recovery:
60254_1.C: In function ‘bool foo(T)’:
60254_1.C:4:3: error: non-constant condition for static assertion
static_assert(foo(i), "Error");
^
60254_1.C:4:3: internal compiler error: unexpected expression ‘foo’ of
kind overload
0x743e15 cxx_eval_constant_expression
../../trunk/gcc/cp/semantics.c:9790
0x7425b6 cxx_eval_call_expression
../../trunk/gcc/cp/semantics.c:8364
0x743d64 cxx_eval_constant_expression
../../trunk/gcc/cp/semantics.c:9487
0x7471e6 cxx_eval_outermost_constant_expr
../../trunk/gcc/cp/semantics.c:9810
0x74fd0d cxx_constant_value
../../trunk/gcc/cp/semantics.c:9895
0x74fd0d finish_static_assert(tree_node*, tree_node*, unsigned int, bool)
../../trunk/gcc/cp/semantics.c:6863
0x6b770b cp_parser_static_assert
../../trunk/gcc/cp/parser.c:11838
Would it be Ok to trivially handle OVERLOAD for the benefit of error
recovery per the attached? The error message we additionally emit makes
sense:
60254_1.C:7:22: error: expression ‘foo’ does not designate a constexpr
function
static_assert(foo(i), "Error");
Thanks!
Paolo.
PS: the second testcase is already fixed.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 208507)
+++ cp/semantics.c (working copy)
@@ -9456,6 +9456,7 @@ cxx_eval_constant_expression (const constexpr_call
case FUNCTION_DECL:
case TEMPLATE_DECL:
case LABEL_DECL:
+ case OVERLOAD:
return t;
case PARM_DECL:
Index: testsuite/g++.dg/cpp0x/static_assert10.C
===================================================================
--- testsuite/g++.dg/cpp0x/static_assert10.C (revision 0)
+++ testsuite/g++.dg/cpp0x/static_assert10.C (working copy)
@@ -0,0 +1,8 @@
+// PR c++/60254
+// { dg-do compile { target c++11 } }
+
+template<typename T> bool foo(T)
+{
+ int i;
+ static_assert(foo(i), "Error"); // { dg-error "non-constant
condition|constexpr function" }
+}
Index: testsuite/g++.dg/cpp0x/static_assert11.C
===================================================================
--- testsuite/g++.dg/cpp0x/static_assert11.C (revision 0)
+++ testsuite/g++.dg/cpp0x/static_assert11.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/60254
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+ template<typename T> bool foo(T)
+ {
+ static_assert(foo(0), "Error"); // { dg-error "non-constant condition" }
+ }
+};