Issue 115118
Summary Error when explicitly specifying return type of generic lambda in constraint?
Labels new issue
Assignees
Reporter Eczbek
    https://godbolt.org/z/Yfsdrnn4E

```cpp
struct foo {
	foo(const foo&) = default;

	foo(auto) requires([]<int = 0> -> bool { return true; }()) {}
};

struct bar { foo x; };

int main() {}
```

```
<source>:4:21: error: substitution into constraint _expression_ resulted in a non-constant _expression_
    4 | foo(auto) requires([]<int = 0> -> bool { return true; }()) {}
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:1:8: note: while checking constraint satisfaction for template 'foo<foo>' required here
    1 | struct foo {
      |        ^~~
<source>:1:8: note: in instantiation of function template specialization 'foo::foo<foo>' requested here
<source>:7:8: note: while declaring the implicit copy constructor for 'bar'
    7 | struct bar { foo x; };
      |        ^
<source>:4:21: note: undefined function 'operator()<0>' cannot be used in a constant _expression_
    4 |         foo(auto) requires([]<int = 0> -> bool { return true; }()) {}
      |                            ^
<source>:4:21: note: declared here
<source>:4:21: error: substitution into constraint _expression_ resulted in a non-constant _expression_
    4 |         foo(auto) requires([]<int = 0> -> bool { return true; }()) {}
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>:1:8: note: while checking constraint satisfaction for template 'foo<foo>' required here
    1 | struct foo {
      |        ^~~
<source>:1:8: note: while substituting deduced template arguments into function template 'foo' [with auto:1 = foo]
<source>:7:8: note: while declaring the implicit move constructor for 'bar'
    7 | struct bar { foo x; };
      | ^
<source>:4:21: note: undefined function 'operator()<0>' cannot be used in a constant _expression_
    4 |         foo(auto) requires([]<int = 0> -> bool { return true; }()) {}
      | ^
<source>:4:21: note: declared here
2 errors generated.
Compiler returned: 1
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to