Issue 163837
Summary Lambda evaluated for constant template parameter of function inside templated generic lambda incorrectly complains about local variables needing captures
Labels new issue
Assignees
Reporter MitalAshok
    This is a reduced example <https://godbolt.org/z/WzshaKvxW>:

```c++
// -std=c++20 -fsyntax-only
template<int N>
void f();

template<class>
struct X {
 using type = decltype([](auto) {
        f<[]{
            int result = 0;
            return result;
        }()>();
    }(0));
};

X<void> l;
```

```
<source>:9:20: error: variable 'result' cannot be implicitly captured in a lambda with no capture-default specified
    9 | return result;
      |                    ^
<source>:7:13: note: while substituting into a lambda _expression_ here
    7 |         f<[]{
      | ^
<source>:6:27: note: in instantiation of function template specialization 'X<void>::(anonymous class)::operator()<int>' requested here
 6 |     using type = decltype([](auto) {
      | ^
<source>:14:9: note: in instantiation of template class 'X<void>' requested here
   14 | X<void> l;
      |         ^
<source>:8:17: note: 'result' declared here
    8 |             int result = 0;
      | ^
<source>:7:11: note: lambda _expression_ begins here
    7 | f<[]{
      |           ^
<source>:7:12: note: capture 'result' by value
 7 |         f<[]{
      |            ^
      | result
<source>:7:12: note: capture 'result' by reference
    7 | f<[]{
      |            ^
      |            &result
<source>:7:12: note: default capture by value
    7 |         f<[]{
      |            ^
 |            =
<source>:7:12: note: default capture by reference
    7 | f<[]{
      |            ^
      |            &
```

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

Reply via email to