public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100893] New: Template argument conversion fails for dependant constant function pointer template parameters
@ 2021-06-03 13:22 jlegg at feralinteractive dot com
  2021-06-03 16:14 ` [Bug c++/100893] " ppalka at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jlegg at feralinteractive dot com @ 2021-06-03 13:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100893
           Summary: Template argument conversion fails for dependant
                    constant function pointer template parameters
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlegg at feralinteractive dot com
  Target Milestone: ---

When compiling this C++ code:
void f();
struct S {using F = void (* const)();};
template <typename T, typename T::F f> void g() {}
void h() {g<S, &f>();}

GCC 11.1.1, and (much) earlier versions, reject it with:
<source>: In function 'void h()':
<source>:4:19: error: no matching function for call to 'g<S, f>()'
    4 | void h() {g<S, &f>();}
      |           ~~~~~~~~^~
<source>:3:45: note: candidate: 'template<class T, typename T::F f> void g()'
    3 | template <typename T, typename T::F f> void g() {}
      |                                             ^
<source>:3:45: note:   template argument deduction/substitution failed:
<source>:4:16: error: could not convert template argument 'f' from 'void (*)()'
to 'void (* const)()'
    4 | void h() {g<S, &f>();}
      |                ^~

My language lawyering isn't good enough to explain why, but I think the
template argument conversion should work, and the compiler should behave as it
does when the const is removed. Similar conversions seem to work if F is a
constant type but not a function pointer, or if the second template parameter
on g is not dependant on the first. MSVC and Clang also accept the example
code.

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

end of thread, other threads:[~2021-06-04 18:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 13:22 [Bug c++/100893] New: Template argument conversion fails for dependant constant function pointer template parameters jlegg at feralinteractive dot com
2021-06-03 16:14 ` [Bug c++/100893] " ppalka at gcc dot gnu.org
2021-06-04 18:10 ` cvs-commit at gcc dot gnu.org
2021-06-04 18:11 ` 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).