https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117436
Bug ID: 117436
Summary: [contracts] Using data member inside a lambda from a
contract fails
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: c++-contracts, c++-lambda, rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
struct f {
int x;
void f2 ()[[pre: [this]{return x;}()]] {}
};
```
Should work too but right now GCC fails with:
```
<source>: In lambda function:
<source>:4:34: error: invalid use of non-static data member 'f::x'
4 | void f2 ()[[pre: [this]{return x;}()]] {}
| ^
<source>:3:7: note: declared here
3 | int x;
| ^
```
If the lambda is moved inside f2's body the lambda works. If we use directly x
from the contract it also works.