public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100594] New: Lambdas in unevaluated contexts interact oddly with alias templates
@ 2021-05-14  1:25 brycelelbach at gmail dot com
  2021-05-14  1:31 ` [Bug c++/100594] " jason at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: brycelelbach at gmail dot com @ 2021-05-14  1:25 UTC (permalink / raw)
  To: gcc-bugs

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.

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

* [Bug c++/100594] Lambdas in unevaluated contexts interact oddly with alias templates
  2021-05-14  1:25 [Bug c++/100594] New: Lambdas in unevaluated contexts interact oddly with alias templates brycelelbach at gmail dot com
@ 2021-05-14  1:31 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: jason at gcc dot gnu.org @ 2021-05-14  1:31 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-05-14
                 CC|                            |jason at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

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

* [Bug c++/100594] Lambdas in unevaluated contexts interact oddly with alias templates
  2021-05-14  1:25 [Bug c++/100594] New: Lambdas in unevaluated contexts interact oddly with alias templates brycelelbach at gmail dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pilarlatiesa at gmail dot com @ 2021-05-17  6:51 UTC (permalink / raw)
  To: gcc-bugs

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

Pilar Latiesa <pilarlatiesa at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pilarlatiesa at gmail dot com

--- Comment #1 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
I think this is the same as PR92211.

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

* [Bug c++/100594] Lambdas in unevaluated contexts interact oddly with alias templates
  2021-05-14  1:25 [Bug c++/100594] New: Lambdas in unevaluated contexts interact oddly with alias templates brycelelbach at gmail dot com
  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
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-13  7:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  1:25 [Bug c++/100594] New: Lambdas in unevaluated contexts interact oddly with alias templates brycelelbach at gmail dot com
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

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