public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106821] New: Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
@ 2022-09-03  5:05 Dylan.Ferris at amd dot com
  2022-10-21 21:30 ` [Bug c++/106821] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Dylan.Ferris at amd dot com @ 2022-09-03  5:05 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-13 15:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-03  5:05 [Bug c++/106821] New: Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context Dylan.Ferris at amd dot com
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

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