https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84981

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-03-19
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed.

Without the lambda:

template<auto> struct X { };

void f()
{
  struct Locale {
    static void f() { }
  };

  X<&Locale::f> x;
}

c12.cc: In function 'void f()':
c12.cc:9:15: error: 'f()::Locale::f' is not a valid template argument for type
'void (*)()' because 'static void f()::Locale::f()' has no linkage
   X<&Locale::f> x;
               ^


This seems to fix it:

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6259,7 +6259,8 @@ convert_nontype_argument_function (tree type, tree expr,
     }

   linkage = decl_linkage (fn_no_ptr);
-  if (cxx_dialect >= cxx11 ? linkage == lk_none : linkage != lk_external)
+  if ((cxx_dialect < cxx11 && linkage != lk_external)
+      || (cxx_dialect < cxx17 && linkage == lk_none))
     {
       if (complain & tf_error)
        {

Reply via email to