https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124088

--- Comment #2 from Matthias Kretz (Vir) <mkretz at gcc dot gnu.org> ---
(see also EWG channel on WG21 Mattermost)

P2900R14 p.46f:
> ## 3.5.11 Mixed Mode
> One important takeaway from having the semantic of evaluation being 
> effectively unspecified until run time is that, unlike a macro-based 
> solution, a contract assertion’s definition — and thus the definition of the 
> function to which it applies — is the same even though individual evaluations 
> of that contract assertion might have different evaluation semantics. This 
> feature means that an implementation that supports mixing translation units 
> where contract assertions are configured to have different evaluation 
> semantics is not, in and of itself, an ODR violation.

I can't follow the implication made in this paragraph. The WD says "[It is
unspecified whether the predicate is
evaluated.](https://eel.is/c++draft/basic.contract#eval-5.sentence-2)". The
above says "semantic of evaluation being effectively unspecified until run
time". But these two are not equivalent. An implementation that chooses to
unconditionally evaluate the semantic according to a certain compiler flag
setting implements "unspecified whether the predicate is evaluated" as *the
predicate is always evaluated*. The implementation is in no way "effectively"
forced to defer until run time. For such an implementation, mixing translation
units with different evaluation semantics leads to ODR violations on inline
functions.

To be blunt, I don't think the wording achieves what the paper says.

That sayd, I agree, that if you want to support (ODR-violating) inline
functions with preconditions that use different checking semantics in different
TUs, then yes, disabling IPA seems to be necessary here. But that's not a fault
of IPA, that's a specific feature of contracts.

Reply via email to