https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124648
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |16.0
Assignee|unassigned at gcc dot gnu.org |iains at gcc dot gnu.org
Ever confirmed|0 |1
CC| |iains at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2026-03-26
Keywords| |ice-on-invalid-code
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
I think that this code is invalid
see https://eel.is/c++draft/expr.prim.lambda#closure-10
Explanation: it is an important provision of contracts that the semantic should
not alter things like what is captured.
However, it should not ICE and I have a fix for that,
which would give:
t.C: In lambda function:
t.C:4:29: error: ‘b’ is not implicitly captured by a contract assertion
4 | auto lambda = [&] pre(a < b) {};
| ^
t.C:3:7: note: ‘b’ declared here
3 | int b = 3;
| ^
t.C:4:25: error: ‘a’ is not implicitly captured by a contract assertion
4 | auto lambda = [&] pre(a < b) {};
| ^
t.C:2:7: note: ‘a’ declared here
2 | int a = 0;
| ^