Bug 99478 - [10 Regression] ICE when decltype lambda in template list
Summary: [10 Regression] ICE when decltype lambda in template list
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.1.0
: P2 normal
Target Milestone: 11.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: 100091
  Show dependency treegraph
 
Reported: 2021-03-09 07:29 UTC by 康桓瑋
Modified: 2023-07-07 09:30 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.5.0
Last reconfirmed: 2021-03-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description 康桓瑋 2021-03-09 07:29:14 UTC
The following code will trigger ICE on gcc-9.1 ~ gcc-trunk with "-std=c++2a" mode:

template <decltype ([] {})> auto f() {}

int main() { f<{}>(); }

(godbolt: https://godbolt.org/z/dEP5PT)
Comment 1 Marek Polacek 2021-03-09 15:00:16 UTC
Started with r269972.  Invalid, I think.
Comment 2 GCC Commits 2021-04-14 04:34:16 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:e1666ebd9ad31dbd8b9b933c883bdd882cfd1522

commit r11-8166-ge1666ebd9ad31dbd8b9b933c883bdd882cfd1522
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 13 22:28:32 2021 -0400

    c++: lambda in non-type template parm type [PR99478]
    
    In this testcase, the non-type template parameter has the type of a
    lambda-expression.  This makes no sense because a lambda in template context
    is specified to be distinct between different specializations of the
    template, even if the lambda is non-dependent, but here which specialization
    we are dealing with depends on which lambda we have, and vice versa.
    
    gcc/cp/ChangeLog:
    
            PR c++/99478
            * parser.c (cp_parser_lambda_expression): Reject lambda
            in template parameter type.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/99478
            * g++.dg/cpp2a/lambda-uneval14.C: New test.
Comment 3 Jason Merrill 2021-04-14 04:34:40 UTC
Fixed for 11 so far.
Comment 4 Richard Biener 2021-06-01 08:19:54 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 5 Richard Biener 2022-05-27 09:44:41 UTC
GCC 9 branch is being closed
Comment 6 Jakub Jelinek 2022-06-28 10:43:54 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 7 Richard Biener 2023-07-07 09:30:52 UTC
Fixed in GCC 11.