public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/102670] New: Erroneous "missing template arguments" message for wrapper of ADL function template @ 2021-10-09 18:51 friedkeenan at protonmail dot com 2021-11-03 15:45 ` [Bug c++/102670] " ppalka at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: friedkeenan at protonmail dot com @ 2021-10-09 18:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102670 Bug ID: 102670 Summary: Erroneous "missing template arguments" message for wrapper of ADL function template Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: friedkeenan at protonmail dot com Target Milestone: --- With the following code, GCC outputs an erroneous error message of "missing template arguments": #include <utility> namespace ns { struct S { }; template<int I> constexpr int adl(const S &) { return I; } } namespace redirect { template<typename T, int I> concept can_call_adl = requires(T &&t) { adl<I>(std::forward<T>(t)); }; template<int I> struct adl_fn { template<can_call_adl<I> T> constexpr decltype(auto) operator ()(T &&t) const { return adl<I>(std::forward<T>(t)); } }; namespace { template<int I> constexpr inline adl_fn<I> adl{}; } } static_assert(redirect::can_call_adl<ns::S, 3>); int main() { // return adl<3>(ns::S{}); return redirect::adl<3>(ns::S{}); } Godbolt link: https://godbolt.org/z/or5n8EM6q As you can see, even though ns::S satisfies the redirect::can_call_adl concept, when the templated call operator is instantiated, it thinks the code is invalid. If you remove the indirection, no error message is presented and everything works as expected. Additionally, Clang handles this code just fine. If you however use the following code, everything works fine: #include <utility> namespace ns { struct S { }; template<int I> constexpr int adl(const S &) { return I; } } namespace redirect { namespace _adl { /* Poison pill. */ template<int I> void adl() = delete; template<typename T, int I> concept can_call_adl = requires(T &&t) { adl<I>(std::forward<T>(t)); }; template<int I> struct adl_fn { template<can_call_adl<I> T> constexpr decltype(auto) operator ()(T &&t) const { return adl<I>(std::forward<T>(t)); } }; } namespace { template<int I> constexpr inline _adl::adl_fn<I> adl{}; } } static_assert(redirect::_adl::can_call_adl<ns::S, 3>); int main() { // return adl<3>(ns::S{}); return redirect::adl<3>(ns::S{}); } Godbolt link: https://godbolt.org/z/jocaKrjbW This sort of functionality is desirable for making a wrapper that handles both ADL-discovered `get` functions and `get` member functions (as structured binding allows both), similar to the std::ranges::begin etc. wrappers. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102670] Erroneous "missing template arguments" message for wrapper of ADL function template 2021-10-09 18:51 [Bug c++/102670] New: Erroneous "missing template arguments" message for wrapper of ADL function template friedkeenan at protonmail dot com @ 2021-11-03 15:45 ` ppalka at gcc dot gnu.org 2021-11-18 15:05 ` cvs-commit at gcc dot gnu.org 2022-01-11 14:00 ` ppalka at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: ppalka at gcc dot gnu.org @ 2021-11-03 15:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102670 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2021-11-03 --- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102670] Erroneous "missing template arguments" message for wrapper of ADL function template 2021-10-09 18:51 [Bug c++/102670] New: Erroneous "missing template arguments" message for wrapper of ADL function template friedkeenan at protonmail dot com 2021-11-03 15:45 ` [Bug c++/102670] " ppalka at gcc dot gnu.org @ 2021-11-18 15:05 ` cvs-commit at gcc dot gnu.org 2022-01-11 14:00 ` ppalka at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2021-11-18 15:05 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102670 --- 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:6fa8e0896c6ec96eddcedb2b92502a7bbb525c03 commit r12-5372-g6fa8e0896c6ec96eddcedb2b92502a7bbb525c03 Author: Patrick Palka <ppalka@redhat.com> Date: Thu Nov 18 10:04:27 2021 -0500 c++: unqual lookup performed twice w/ template-id ADL [PR102670] Here we're incorrectly performing unqualified lookup of 'adl' again at substitution time for the call adl<I>(t) (for which name lookup at parse time found nothing) which causes us to reject the testcase because the second unqualified lookup finds the later-declared variable template 'adl', leading to confusion. Fixed thusly. The testcase concepts-recursive-sat1.C needed to be adjusted to use ADL proper instead of relying on this incorrect second unqualified lookup. PR c++/102670 gcc/cp/ChangeLog: * pt.c (tsubst_copy_and_build) <case CALL_EXPR>: When looking for an identifier callee in the koenig_p case, also look through TEMPLATE_ID_EXPR. Use tsubst_copy to substitute through the template arguments of the template-id. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-recursive-sat1.C: Adjust to use ADL proper. * g++.dg/cpp2a/fn-template23.C: New test. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/102670] Erroneous "missing template arguments" message for wrapper of ADL function template 2021-10-09 18:51 [Bug c++/102670] New: Erroneous "missing template arguments" message for wrapper of ADL function template friedkeenan at protonmail dot com 2021-11-03 15:45 ` [Bug c++/102670] " ppalka at gcc dot gnu.org 2021-11-18 15:05 ` cvs-commit at gcc dot gnu.org @ 2022-01-11 14:00 ` ppalka at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-01-11 14:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102670 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |12.0 Status|ASSIGNED |RESOLVED 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:[~2022-01-11 14:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-09 18:51 [Bug c++/102670] New: Erroneous "missing template arguments" message for wrapper of ADL function template friedkeenan at protonmail dot com 2021-11-03 15:45 ` [Bug c++/102670] " ppalka at gcc dot gnu.org 2021-11-18 15:05 ` cvs-commit at gcc dot gnu.org 2022-01-11 14:00 ` 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).