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
* [Bug c++/100893] Template argument conversion fails for dependant constant function pointer template parameters 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 ` 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 2 siblings, 0 replies; 4+ messages in thread From: ppalka at gcc dot gnu.org @ 2021-06-03 16:14 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100893 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2021-06-03 CC| |ppalka at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> --- Confirmed, this never worked it seems. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/100893] Template argument conversion fails for dependant constant function pointer template parameters 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 2 siblings, 0 replies; 4+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-06-04 18:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100893 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:6f8c9691495ad5a307db98dc19c3296ee4e6de64 commit r12-1224-g6f8c9691495ad5a307db98dc19c3296ee4e6de64 Author: Patrick Palka <ppalka@redhat.com> Date: Fri Jun 4 14:08:26 2021 -0400 c++: top-level cv-quals on type of NTTP [PR100893] Here, we're rejecting the specialization of g<T,F> with T=A, F=&f in param4.C below due to a spurious constness mismatch between the type of the template argument &f and the substituted type of the parm F (the latter has a top-level const). Note that this mismatch doesn't occur with object pointers because in that case a call to perform_qualification_conversions from convert_nontype_argument implicitly adds a top-level const to the argument (via a cast) to match. This however seems to be a manifestation of a more general conformance issue: we're not dropping top-level cv-quals on the substituted type of an NTTP as per [temp.param]/6 (we only do so at parse time in process_template_parm). So this patch makes convert_template_argument drop top-level cv-quals accordingly. PR c++/100893 gcc/cp/ChangeLog: * pt.c (convert_template_argument): Strip top-level cv-quals on the substituted type of a non-type template parameter. gcc/testsuite/ChangeLog: * g++.dg/template/param4.C: New test. * g++.dg/template/param5.C: New test. * g++.dg/cpp1z/nontype-auto19.C: New test. * g++.dg/cpp2a/concepts-decltype.C: Don't expect that the deduced type of a decltype(auto) NTTP has top-level cv-quals. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/100893] Template argument conversion fails for dependant constant function pointer template parameters 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 2 siblings, 0 replies; 4+ messages in thread From: ppalka at gcc dot gnu.org @ 2021-06-04 18:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100893 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |rejects-valid Status|ASSIGNED |RESOLVED Target Milestone|--- |12.0 Resolution|--- |FIXED --- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- Fixed for GCC 12, thanks for the bug report! ^ 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).