Full name of submitter (unless configured in github; will be published with the issue): Joshua Berne
Reference (section label): [dcl.contract.func] p9
Link to reflector thread (if any):
Issue description: Currently we require a function's contract assertions to be valid when the function is odr-used. This is fine in C++26 because calling a function always gets you to that function's definition.
With P3097 and contracts on virtual functions, we have a separate issue that calling a pure virtual function doesn't odr-use that function (because odr-use is about wanting the definition, not he declaration). We already have a similar seemingly-redundant carveout in the definition of needed for exception specifications where we say "in an expression, the function is selected by overload resolution" in addition to the case where the function is odr-used.
Therefore we need to add a similar bullet to when we need a function's function-contract-assertions. Since it is only evaluation that matters (and the assertions are not and never will be part of the type or relevant in unevaluated expressions) I think we need a parallel to the first bullet in [except.spec]p13 but limited to potentially-evaluated expressions.
Suggested resolution:
The function contract assertions of a function are considered to be needed (13.9.2) when
— in a potentially evaluated expression, the function is selected by overload resolution ([over.match],[over.over]),
— the function is odr-used ([basic.def.odr]) or
— the function is defined.
Full name of submitter (unless configured in github; will be published with the issue): Joshua Berne
Reference (section label): [dcl.contract.func] p9
Link to reflector thread (if any):
Issue description: Currently we require a function's contract assertions to be valid when the function is odr-used. This is fine in C++26 because calling a function always gets you to that function's definition.
With P3097 and contracts on virtual functions, we have a separate issue that calling a pure virtual function doesn't odr-use that function (because odr-use is about wanting the definition, not he declaration). We already have a similar seemingly-redundant carveout in the definition of needed for exception specifications where we say "in an expression, the function is selected by overload resolution" in addition to the case where the function is odr-used.
Therefore we need to add a similar bullet to when we need a function's function-contract-assertions. Since it is only evaluation that matters (and the assertions are not and never will be part of the type or relevant in unevaluated expressions) I think we need a parallel to the first bullet in [except.spec]p13 but limited to potentially-evaluated expressions.
Suggested resolution:
The function contract assertions of a function are considered to be needed (13.9.2) when
— in a potentially evaluated expression, the function is selected by overload resolution ([over.match],[over.over]),
— the function is odr-used ([basic.def.odr]) or
— the function is defined.