public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/99209] New: lambdas in function template signatures instantiated with wrong semantic context @ 2021-02-22 20:46 richard-gccbugzilla at metafoo dot co.uk 2021-02-22 21:11 ` [Bug c++/99209] " richard-gccbugzilla at metafoo dot co.uk ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: richard-gccbugzilla at metafoo dot co.uk @ 2021-02-22 20:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99209 Bug ID: 99209 Summary: lambdas in function template signatures instantiated with wrong semantic context Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: richard-gccbugzilla at metafoo dot co.uk Target Milestone: --- Testcase: constexpr decltype(auto) f_adl(auto a) { return f(a); } namespace A { constexpr int f(auto) { return 0; } template<int = f_adl([]{})> void g(int = f_adl([]{})) { f_adl([]{}); } } int main() { A::g(); } Here, the f_adl calls for the default template argument and default function argument incorrectly result in errors, because f can't be found by ADL. I suspect this is because the lambdas are being created in the wrong semantic context. (That is also visible in the output of __PRETTY_FUNCTION__ / std::source_location::current().function_name() in the lambda and in the mangling of the lambda closure type, but I think both of those are valid implementation choices -- the function name is implementation-defined and such instantiated lambdas appear to be numbered after those lambdas for which the ABI requires a numbering). ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99209] lambdas in function template signatures instantiated with wrong semantic context 2021-02-22 20:46 [Bug c++/99209] New: lambdas in function template signatures instantiated with wrong semantic context richard-gccbugzilla at metafoo dot co.uk @ 2021-02-22 21:11 ` richard-gccbugzilla at metafoo dot co.uk 2021-03-03 21:12 ` mpolacek at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: richard-gccbugzilla at metafoo dot co.uk @ 2021-02-22 21:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99209 --- Comment #1 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> --- Here's a more interesting example: https://godbolt.org/z/83c36q #include <iostream> constexpr char f(...) { return 'g'; } constexpr decltype(auto) f_adl(auto a) { return f(a); } namespace A { constexpr char f(auto) { return 'A'; } template<char TemplateParam = f_adl([]{})> void g(char FunctionParam = f_adl([]{})) { char Local = f_adl([]{}); std::cout << TemplateParam << FunctionParam << Local; } } namespace B { constexpr char f(auto) { return 'B'; } void call() { A::g(); } } int main() { B::call(); } This prints 'BgA', but should print 'AAA'. So the three lambdas actually exhibit three different behaviors, not two. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99209] lambdas in function template signatures instantiated with wrong semantic context 2021-02-22 20:46 [Bug c++/99209] New: lambdas in function template signatures instantiated with wrong semantic context richard-gccbugzilla at metafoo dot co.uk 2021-02-22 21:11 ` [Bug c++/99209] " richard-gccbugzilla at metafoo dot co.uk @ 2021-03-03 21:12 ` mpolacek at gcc dot gnu.org 2022-09-08 14:51 ` cvs-commit at gcc dot gnu.org 2022-09-08 14:55 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: mpolacek at gcc dot gnu.org @ 2021-03-03 21:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99209 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mpolacek at gcc dot gnu.org Last reconfirmed| |2021-03-03 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99209] lambdas in function template signatures instantiated with wrong semantic context 2021-02-22 20:46 [Bug c++/99209] New: lambdas in function template signatures instantiated with wrong semantic context richard-gccbugzilla at metafoo dot co.uk 2021-02-22 21:11 ` [Bug c++/99209] " richard-gccbugzilla at metafoo dot co.uk 2021-03-03 21:12 ` mpolacek at gcc dot gnu.org @ 2022-09-08 14:51 ` cvs-commit at gcc dot gnu.org 2022-09-08 14:55 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-09-08 14:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99209 --- Comment #3 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:f7280b04714c24af2854cf020b6e7b6ad3b7fba8 commit r13-2542-gf7280b04714c24af2854cf020b6e7b6ad3b7fba8 Author: Patrick Palka <ppalka@redhat.com> Date: Thu Sep 8 10:49:04 2022 -0400 c++: Add testcase for already fixed PR [PR99209] This was incidentally fixed by r13-806-g221acd67ca50f8. PR c++/99209 gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-uneval17.C: New test. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/99209] lambdas in function template signatures instantiated with wrong semantic context 2021-02-22 20:46 [Bug c++/99209] New: lambdas in function template signatures instantiated with wrong semantic context richard-gccbugzilla at metafoo dot co.uk ` (2 preceding siblings ...) 2022-09-08 14:51 ` cvs-commit at gcc dot gnu.org @ 2022-09-08 14:55 ` ppalka at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: ppalka at gcc dot gnu.org @ 2022-09-08 14:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99209 Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=105652 Target Milestone|--- |12.2 Resolution|--- |FIXED CC| |ppalka at gcc dot gnu.org --- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> --- This appears to be fixed for GCC 12.2/trunk by the fix for PR105652. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-09-08 14:55 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-02-22 20:46 [Bug c++/99209] New: lambdas in function template signatures instantiated with wrong semantic context richard-gccbugzilla at metafoo dot co.uk 2021-02-22 21:11 ` [Bug c++/99209] " richard-gccbugzilla at metafoo dot co.uk 2021-03-03 21:12 ` mpolacek at gcc dot gnu.org 2022-09-08 14:51 ` cvs-commit at gcc dot gnu.org 2022-09-08 14:55 ` 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).