Hi,

this ICE on valid, [4.7/4.8/4.9 Regression], happens only with -std=c++11 and is quite simple to analyze: cxx_eval_constant_expression sees a COMPONENT_REF and forwards to cxx_eval_component_reference, but the latter, evidently, only handles "fields" not functions (per the comment) and an ICE soon happens when it tries to use DECL_MUTABLE_P.

If, for comparison, instead of a static member function, we have a static free function, like in, eg

static void foo();

template<typename> void bar()
{
  foo;
}

what happens is that cxx_eval_constant_expression sees a FUNCTION_DECL and returns it as-is. Thus I believe that doing the same in the case at issue should be fine.

Tested x86_64-linux.

Thanks,
Paolo.

/////////////////////////
/cp
2013-10-20  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58647
        * semantics.c (cxx_eval_constant_expression, [COMPONENT_REF]):
        Handle functions as TREE_OPERAND (t, 1).

/testsuite
2013-10-20  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58647
        * g++.dg/parse/crash66.C: New.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 203876)
+++ cp/semantics.c      (working copy)
@@ -9553,6 +9558,8 @@ cxx_eval_constant_expression (const constexpr_call
       break;
 
     case COMPONENT_REF:
+      if (is_overloaded_fn (TREE_OPERAND (t, 1)))
+       return t;
       r = cxx_eval_component_reference (call, t, allow_non_constant, addr,
                                        non_constant_p, overflow_p);
       break;
Index: testsuite/g++.dg/parse/crash66.C
===================================================================
--- testsuite/g++.dg/parse/crash66.C    (revision 0)
+++ testsuite/g++.dg/parse/crash66.C    (working copy)
@@ -0,0 +1,11 @@
+// PR c++/58647
+
+struct A
+{
+  static void foo();
+};
+
+template<typename> void bar()
+{
+  A().foo;
+}

Reply via email to