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

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).