public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter
@ 2020-11-03 14:14 ensadc at mailnesia dot com
  2020-11-03 14:21 ` [Bug c++/97700] " ensadc at mailnesia dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ensadc at mailnesia dot com @ 2020-11-03 14:14 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-12 15:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 14:14 [Bug c++/97700] New: Bogus error when a class containing a function pointer is used as a non-type template parameter ensadc at mailnesia dot com
2020-11-03 14:21 ` [Bug c++/97700] " ensadc at mailnesia dot com
2020-11-19 18:54 ` mpolacek at gcc dot gnu.org
2021-03-13 21:42 ` johelegp at gmail dot com
2023-03-17 17:57 ` pinskia at gcc dot gnu.org
2023-05-09 21:23 ` mail at lboeger dot de
2023-05-10 13:13 ` ppalka at gcc dot gnu.org
2023-05-11 14:05 ` cvs-commit at gcc dot gnu.org
2023-05-11 14:25 ` ppalka at gcc dot gnu.org
2023-05-12 15:08 ` cvs-commit at gcc dot gnu.org
2023-05-12 15:25 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).