public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter
@ 2021-04-15  7:05 pilarlatiesa at gmail dot com
  2021-04-15  8:21 ` [Bug c++/100091] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pilarlatiesa at gmail dot com @ 2021-04-15  7:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100091
           Summary: decltype([]{}) rejected as a default template
                    parameter
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

This piece of code is accepted by 10.2, but rejected by yesterday's (20210414)
snapshot:

$ cat test.cpp

  template<typename = decltype([]{})>
  void f() {}

$ ../GCC-11/bin/g++ -std=c++20 -c test.cpp

test.cpp:2:30: error: lambda-expression in template parameter type
    2 | template<typename = decltype([]{})>
      |

It's a recent change in behaviour. Possibly caused by
r11-8166-ge1666ebd9ad31dbd8b9b933c883bdd882cfd1522.

I'm labeling this as rejects-valid because I believe [basic.def.odr]/14 allows
such an use of a lambda, but I hardly understand that wording.

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
@ 2021-04-15  8:21 ` rguenth at gcc dot gnu.org
  2021-04-15 11:50 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-15  8:21 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P1
            Summary|decltype([]{}) rejected as  |[11 Regression]
                   |a default template          |decltype([]{}) rejected as
                   |parameter                   |a default template
                   |                            |parameter
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.0
      Known to work|                            |10.3.0
   Last reconfirmed|                            |2021-04-15

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
  2021-04-15  8:21 ` [Bug c++/100091] [11 Regression] " rguenth at gcc dot gnu.org
@ 2021-04-15 11:50 ` marxin at gcc dot gnu.org
  2021-04-15 12:33 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-04-15 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
> It's a recent change in behaviour. Possibly caused by
> r11-8166-ge1666ebd9ad31dbd8b9b933c883bdd882cfd1522.

I can confirm that.

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
  2021-04-15  8:21 ` [Bug c++/100091] [11 Regression] " rguenth at gcc dot gnu.org
  2021-04-15 11:50 ` marxin at gcc dot gnu.org
@ 2021-04-15 12:33 ` rguenth at gcc dot gnu.org
  2021-04-15 13:32 ` pilarlatiesa at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-15 12:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Of course such use of a lambda is quite pointless which in turn makes the P1
classification a bit odd (but given it's a new regression it's technically
correct).  We'll be happy to demote this to P2 though.

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
                   ` (2 preceding siblings ...)
  2021-04-15 12:33 ` rguenth at gcc dot gnu.org
@ 2021-04-15 13:32 ` pilarlatiesa at gmail dot com
  2021-04-15 15:25 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pilarlatiesa at gmail dot com @ 2021-04-15 13:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Pilar Latiesa <pilarlatiesa at gmail dot com> ---
> Of course such use of a lambda is quite pointless 

Not as pointless as it might appear. This defaulted template parameter enables
a form of stateful metaprogramming:

#include <type_traits>

template<typename, typename = decltype([]{})>
class T {};

static_assert(!std::is_same_v<T<int>, T<int>>); // passes with GCC 10

I don’t know if that is valid C++, and would love to know whether or not it is.

On the other hand, sometimes it is convenient to use lambdas this way:

template<typename TOp = decltype([](double x) { return x * x; })>
class my_functor
{
  [[no_unique_address]] TOp const Op = {};
};

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
                   ` (3 preceding siblings ...)
  2021-04-15 13:32 ` pilarlatiesa at gmail dot com
@ 2021-04-15 15:25 ` jason at gcc dot gnu.org
  2021-04-15 16:56 ` jason at gcc dot gnu.org
  2023-07-07  9:30 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-15 15:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
                   ` (4 preceding siblings ...)
  2021-04-15 15:25 ` jason at gcc dot gnu.org
@ 2021-04-15 16:56 ` jason at gcc dot gnu.org
  2023-07-07  9:30 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-15 16:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed in r11-8199

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

* [Bug c++/100091] [11 Regression] decltype([]{}) rejected as a default template parameter
  2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
                   ` (5 preceding siblings ...)
  2021-04-15 16:56 ` jason at gcc dot gnu.org
@ 2023-07-07  9:30 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

Bug 99478 Summary: [10 Regression] ICE when decltype lambda in template list
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99478

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

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

end of thread, other threads:[~2023-07-07  9:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-15  7:05 [Bug c++/100091] New: decltype([]{}) rejected as a default template parameter pilarlatiesa at gmail dot com
2021-04-15  8:21 ` [Bug c++/100091] [11 Regression] " rguenth at gcc dot gnu.org
2021-04-15 11:50 ` marxin at gcc dot gnu.org
2021-04-15 12:33 ` rguenth at gcc dot gnu.org
2021-04-15 13:32 ` pilarlatiesa at gmail dot com
2021-04-15 15:25 ` jason at gcc dot gnu.org
2021-04-15 16:56 ` jason at gcc dot gnu.org
2023-07-07  9:30 ` rguenth 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).