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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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 ` pinskia at gcc dot gnu.org
  2022-10-21 21:30 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 21:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 53751
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53751&action=edit
testcase 1

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 21:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 53752
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53752&action=edit
testcase 2

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 21:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 53753
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53753&action=edit
testcase 3

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (2 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 21:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |106221

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think the first example is PR 106221.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106221
[Bug 106221] lamba inside a decltype in a using statement does not always work

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (3 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-21 21:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually I think all three examples are that other PR.

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (4 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-13  8:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed on the trunk for GCC 14 by the recent lambda template patches.

Note testcase 3 is rejected by clang (but since it is accepted by EDG, MSVC and
now GCC, I suspect it is a clang bug).

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (5 preceding siblings ...)
  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
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-13 15:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821
Bug 106821 depends on bug 106221, which changed state.

Bug 106221 Summary: lamba inside a decltype in a using statement does not always work
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106221

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

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

* [Bug c++/106821] Incorrect behavior when using type alias template containing unevaluated lambda expression in a template context
  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
                   ` (6 preceding siblings ...)
  2024-04-13 15:13 ` ppalka at gcc dot gnu.org
@ 2024-04-13 15:14 ` ppalka at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-13 15:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106821
Bug 106821 depends on bug 106221, which changed state.

Bug 106221 Summary: lamba inside a decltype in a using statement does not always work
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106221

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |NEW
         Resolution|DUPLICATE                   |---

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