Hi,
this is an ICE on valid, 4.6/4.7 Regression, which manifests itself as
tree codes unhandled by cxx_eval_constant_expression. The patchlet below
appears to fix the issue and passes testing on x86_64-linux.
Ok for mainline? Branch too?
Thanks,
Paolo.
////////////////////////////
/cp
2011-11-16 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51150
* semantics.c (cxx_eval_constant_expression): Handle ARROW_EXPR,
CAST_EXPR, CONST_CAST_EXPR, STATIC_CAST_EXPR, REINTERPRET_CAST_EXPR.
/testsuite
2011-11-16 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51150
* g++.dg/cpp0x/pr51150.C: New.
Index: testsuite/g++.dg/cpp0x/pr51150.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr51150.C (revision 0)
+++ testsuite/g++.dg/cpp0x/pr51150.C (revision 0)
@@ -0,0 +1,20 @@
+// PR c++/51150
+// { dg-options "-std=c++0x" }
+
+struct Clock {
+ double Now();
+};
+template <class T> void Foo(Clock* clock) {
+ const int now = clock->Now();
+}
+
+template void Foo<float>(Clock*);
+
+template <class T> void Boo(int val) {
+ const int now1 = (double)(val);
+ const int now2 = const_cast<double>(val); // { dg-error "invalid" }
+ const int now3 = static_cast<double>(val);
+ const int now4 = reinterpret_cast<double>(val); // { dg-error "invalid" }
+}
+
+template void Boo<float>(int);
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 181407)
+++ cp/semantics.c (working copy)
@@ -7711,6 +7711,11 @@ cxx_eval_constant_expression (const constexpr_call
case THROW_EXPR:
case MODIFY_EXPR:
case MODOP_EXPR:
+ case ARROW_EXPR:
+ case CAST_EXPR:
+ case CONST_CAST_EXPR:
+ case STATIC_CAST_EXPR:
+ case REINTERPRET_CAST_EXPR:
/* GCC internal stuff. */
case VA_ARG_EXPR:
case OBJ_TYPE_REF: