Issue |
80997
|
Summary |
lambda with `this auto` that captures `this` in a member function is not an integral constant _expression_
|
Labels |
new issue
|
Assignees |
|
Reporter |
hewillk
|
https://godbolt.org/z/azqxac8xE
```cpp
struct S {
int i = 42;
constexpr auto f() {
return [this](this auto) {
return this->i;
}();
};
};
static_assert(S().f() == 42);
```
Clang rejects the above code with:
```
<source>:10:15: error: static assertion _expression_ is not an integral constant _expression_
10 | static_assert(S().f() == 42);
| ^~~~~~~~~~~~~
<source>:5:14: note: use of 'this' pointer is only allowed within the evaluation of a call to a 'constexpr' member function
5 | return this->i;
| ^
```
If we remove `this auto` then [compile fine](https://godbolt.org/z/Gb8qE7Whh), the two should be equivalent right?
Not really sure what the standards say about this.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs