On 11/27/2013 04:35 PM, Jason Merrill wrote:
On 11/27/2013 05:22 AM, Paolo Carlini wrote:
Thus something like the below? Passes testing.

Yep. With a comment that we can only get there in checking mode via build_non_dependent_expr, because any expression that calls or takes the address of the function will have pull a FUNCTION_DECL out of the COMPONENT_REF.
Agreed, I applied the below. Since the issue doesn't affect release-mode for the time being at least I'm not going to fiddle with 4.7/4.8.

Thanks,
Paolo.

///////////////////
/cp
2013-11-27  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58647
        * semantics.c (cxx_eval_constant_expression, [COMPONENT_REF]):
        Handle function COMPONENT_REFs.

/testsuite
2013-11-27  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58647
        * g++.dg/parse/crash66.C: New.
Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 205448)
+++ cp/semantics.c      (working copy)
@@ -9603,6 +9603,16 @@ cxx_eval_constant_expression (const constexpr_call
       break;
 
     case COMPONENT_REF:
+      if (is_overloaded_fn (t))
+       {
+         /* We can only get here in checking mode via 
+            build_non_dependent_expr,  because any expression that
+            calls or takes the address of the function will have
+            pulled a FUNCTION_DECL out of the COMPONENT_REF.  */
+         gcc_checking_assert (allow_non_constant);
+         *non_constant_p = true;
+         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