https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700
Bug ID: 97700
Summary: Bogus error when a class containing a function pointer
is used as a non-type template parameter
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ensadc at mailnesia dot com
CC: jason at redhat dot com
Target Milestone: ---
Originally discovered by cigien on StackOverflow. See
https://stackoverflow.com/questions/64655958/can-a-class-containing-a-function-pointer-be-used-as-a-non-type-template-parameter
GCC does not like this program:
````
struct S
{
void (*f)();
};
constexpr S s {[]{}};
template<S> struct X {};
using x = X<s>;
````
It complains with:
````
error: '<lambda()>::_FUN' is not a valid template argument of type 'void (*)()'
because '<lambda()>::_FUN' is not a variable
using x = X<s>;
^
````
As mentioned in the StackOverflow post, it appears that
`invalid_tparm_referent_p` (called by `get_template_parm_object`) fails to
account for the pointer-to-function case.