https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84981
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And maybe also this for references as template arguments:
--- 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)
{
But I think there's more needed to ensure we don't produce invalid GIMPLE.