Skip to content

[basic.def.odr] Make a lambda contract predicate odr-usable for captures#12

Open
abhinavagarwal07 wants to merge 1 commit into
mainfrom
fix-odr-usable-lambda-contract
Open

[basic.def.odr] Make a lambda contract predicate odr-usable for captures#12
abhinavagarwal07 wants to merge 1 commit into
mainfrom
fix-odr-usable-lambda-contract

Conversation

@abhinavagarwal07

Copy link
Copy Markdown
Owner

The odr-usability rule's lambda bullet (the fourth inner bullet of [basic.def.odr] p10) requires the lambda's block scope to be an intervening scope. But a function contract predicate (e.g. [i] pre(i > 0) {}) lives in the lambda-declarator, in a contract-assertion scope that is outside the block scope, so a literal reading makes the normative [expr.prim.lambda] example auto f3 = [i] pre(i > 0) {}; // OK ill-formed. Allow the second conjunct to be satisfied by a contract-assertion scope introduced by a function contract assertion of the lambda-expression, in addition to its block scope. The CWG 2380 default-argument case ([=](int k = n) {}) remains ill-formed.

The odr-usability rule's lambda bullet (bullet 4) required the lambda's
block scope to be an intervening scope, but a function contract predicate
(e.g. [i] pre(i > 0) {}) lives in the lambda-declarator, in a
contract-assertion scope outside the block scope. This made the
normative [expr.prim.lambda] example "auto f3 = [i] pre(i > 0) {}; // OK"
ill-formed. Allow the second conjunct to be satisfied by a
contract-assertion scope introduced by a function contract assertion of
the lambda-expression, in addition to its block scope, while preserving
the CWG 2380 default-argument case as ill-formed.
@abhinavagarwal07 abhinavagarwal07 force-pushed the fix-odr-usable-lambda-contract branch from 0761cc1 to 564f445 Compare June 17, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant