Bug 92556 - [10 Regression] ICE if using dependent name inside lambda expression in simple-requirement since r10-3735-gcb57504a55015891
Summary: [10 Regression] ICE if using dependent name inside lambda expression in simpl...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: 10.0
Assignee: Jason Merrill
URL:
Keywords: accepts-invalid, c++-lambda, ice-on-invalid-code
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2019-11-18 07:40 UTC by Ryou Ezoe
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.2.0
Known to fail: 10.0
Last reconfirmed: 2020-01-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryou Ezoe 2019-11-18 07:40:13 UTC
This code produced ICE on GCC 10 2019-11-12.

template < typename T >
    requires requires
{
    // ICE
    []{ T::value ; } ;
}
void f()
{ }

struct S { inline static int value = 0 ; } ;

int main ()
{
    // ill-formed.
    f< int >() ;
    // should be well-formed?
    f< S >() ;
}


https://wandbox.org/permlink/cIj1qRiKzEh9ZYfw

If my understanding on P0315r4 is right, f<int> is ill-formed, and f<S> is well-formed.

GCC messages.

prog.cc: In lambda function:
prog.cc:5:9: internal compiler error: in dependent_type_p, at cp/pt.c:25933
    5 |     []{ T::value ; } ;
      |         ^
0x5a50dc dependent_type_p(tree_node*)
	../../source/gcc/cp/pt.c:25933
0x7062e7 dependent_scope_p(tree_node*)
	../../source/gcc/cp/pt.c:25968
0x7062e7 tsubst_qualified_id
	../../source/gcc/cp/pt.c:15852
0x6e3633 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:19081
0x6ec286 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:18753
0x6ec286 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:18411
0x6eb71b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17497
0x6eb71b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17526
0x6eacf9 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17497
0x6eacf9 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17814
0x6eacf9 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17497
0x6eacf9 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17814
0x7018e5 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:17497
0x7018e5 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
	../../source/gcc/cp/pt.c:18707
0x6e56c3 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:20099
0x6ec286 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:18753
0x6ec286 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
	../../source/gcc/cp/pt.c:18411
0x61ef93 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
	../../source/gcc/cp/constraint.cc:1818
0x6e4e49 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:20130
0x6ec286 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool)
	../../source/gcc/cp/pt.c:18753
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Comment 1 Martin Liška 2020-01-30 10:28:44 UTC
Started to ICE with r10-3735-gcb57504a55015891, before that we rejected that like clang:

pr92556.cc:2:5: error: ‘requires’ does not name a type
    2 |     requires requires
      |     ^~~~~~~~
pr92556.cc: In function ‘int main()’:
pr92556.cc:15:14: error: no matching function for call to ‘f<int>()’
   15 |     f< int >() ;
      |              ^
pr92556.cc:17:12: error: no matching function for call to ‘f<S>()’
   17 |     f< S >() ;
      |            ^

$ clang++ pr92556.cc -c -std=c++2a
pr92556.cc:2:14: error: expected expression
    requires requires
             ^
pr92556.cc:15:5: error: use of undeclared identifier 'f'
    f< int >() ;
    ^
pr92556.cc:17:8: error: use of undeclared identifier 'S'
    f< S >() ;
       ^
3 errors generated.
Comment 2 GCC Commits 2020-02-15 14:09:29 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:1e166191ef330f3491d405bf3eb09b2b796c9b0e

commit r10-6649-g1e166191ef330f3491d405bf3eb09b2b796c9b0e
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Feb 15 14:48:08 2020 +0100

    c++: Fix lambda in atomic constraint.
    
    find_template_parameters needs to find the mention of T in the lambda.
    Fixing that leaves this as a hard error, which may be surprising but is
    consistent with lambdas in other SFINAE contexts like template argument
    deduction.
    
    gcc/cp/ChangeLog
    2020-02-15  Jason Merrill  <jason@redhat.com>
    
    	PR c++/92556
    	* pt.c (any_template_parm_r): Look into lambda body.
Comment 3 Jason Merrill 2020-02-15 15:38:21 UTC
Fixed.