public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "brycelelbach at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100594] New: Lambdas in unevaluated contexts interact oddly with alias templates Date: Fri, 14 May 2021 01:25:31 +0000 [thread overview] Message-ID: <bug-100594-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100594 Bug ID: 100594 Summary: Lambdas in unevaluated contexts interact oddly with alias templates Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: brycelelbach at gmail dot com Target Milestone: --- This code: ``` template <typename T> struct identity {}; template <int N> using A = decltype([] () constexpr { return int{}; }()); template <int N> using B = identity<A<N>>; ``` Is incorrectly rejected by GCC in C++20 mode: ``` <source>:7:23: error: template argument 1 is invalid 7 | using B = identity<A<N>>; | ^~ ASM generation compiler returned: 1 <source>:7:23: error: template argument 1 is invalid 7 | using B = identity<A<N>>; | ^~ Execution build compiler returned: 1 ``` https://godbolt.org/z/hGjfvjGzc For context, I ran into this while writing this code: https://godbolt.org/z/36xz8zGMd I discussed this with Ville and Jason via email: Ville wrote: > Specifically looks like there's an interaction with an alias template > here, because > > decltype([] () constexpr { return int{}; }())* oink; > static_assert(std::is_same_v<decltype(oink), int*>); > > is just fine according to GCC. Jason wrote: > Yeah, how (unevaluated) lambdas should interact with alias templates is > unclear, connected to various existing alias template issues around exactly > how transparent (or not) they are. > > You could work around this with a class template or variable template > that forces the lambda instantiation to be delayed until we have a full > set of template arguments.
next reply other threads:[~2021-05-14 1:25 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-14 1:25 brycelelbach at gmail dot com [this message] 2021-05-14 1:31 ` [Bug c++/100594] " jason at gcc dot gnu.org 2021-05-17 6:51 ` pilarlatiesa at gmail dot com 2024-04-13 7:50 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100594-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).