public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "Dylan.Ferris at amd dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106821] New: Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context Date: Sat, 03 Sep 2022 05:05:47 +0000 [thread overview] Message-ID: <bug-106821-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821 Bug ID: 106821 Summary: Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Dylan.Ferris at amd dot com Target Milestone: --- I have prepared three different examples for when this fails: https://godbolt.org/z/G8Eq5fo5G https://godbolt.org/z/fajvnfo91 https://godbolt.org/z/e9s9Ws5o7 In the first one, `z.obj.a()` should be valid because `obj` is simply an instantiation of the `A` template. In the second one, `z.a()` should be valid because `bar` is inheriting from an instantiation of the `A` template. In the third one, `obj.a()` should be valid because `obj` is simply an instantiation of the `A` template. All three of these have the following in common: 1. `alias` contains an unevaluated lambda expression, ie. `decltype([]{})` 2. The instantiation of `alias` as the inherited type uses a template parameter So, this means that the three examples correctly compile if we apply any of the following workarounds: 1. "inline" the alias by replacing all instances of it with `A<decltype([]{})>` (Requiring this workaround violates [temp.alias.2]) 2. Remove the unevaluated lambda expression from `alias` (such as replacing it with `int`) 3. Remove the template parameter of `alias` 4. Instantiate `alias` with a fixed type such as `int`. The bug persists even under a variety of transformations. Such as: 1. Removing the template on `A` and instead making an expression such as: template<typename T> using alias = std::conditional_t<true, A, decltype([]{})>; 2. Providing `bar`'s template parameter a default value of `int` and subsequently using it I believe this is related to PR 92707, but here the type of the unevaluated lambda is used as a template parameter in each case, and it holds true in what seems to be all template contexts.
next reply other threads:[~2022-09-03 5:05 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-03 5:05 Dylan.Ferris at amd dot com [this message] 2022-10-21 21:30 ` [Bug c++/106821] " pinskia at gcc dot gnu.org 2022-10-21 21:30 ` pinskia at gcc dot gnu.org 2022-10-21 21:30 ` pinskia at gcc dot gnu.org 2022-10-21 21:47 ` pinskia at gcc dot gnu.org 2022-10-21 21:47 ` pinskia at gcc dot gnu.org 2024-04-13 8:13 ` pinskia at gcc dot gnu.org 2024-04-13 15:13 ` ppalka at gcc dot gnu.org 2024-04-13 15:14 ` ppalka 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-106821-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).