C++ Logo

sg15

Advanced search

Re: [isocpp-sg15] [isocpp-sg21] P3835 -- Different contract checking for different libraries

From: Timur Doumler <cpp_at_[hidden]>
Date: Wed, 15 Oct 2025 15:30:45 +0300
> On 15 Oct 2025, at 15:20, Ran Regev <regev.ran_at_[hidden]> wrote:
>
>
>
> On Wed, Oct 15, 2025, 14:10 Timur Doumler via SG15 <sg15_at_[hidden] <mailto:sg15_at_[hidden]>> wrote:
>> Specifically about the inconsistency that Tom highlighted:
>>
>> Please correct me if I'm wrong, but if I remember correctly, we discussed this point specifically when reviewing the P3471 wording in CWG+LWG. From what I remember, the outcome of that discussion was that we can (and did) write in the wording that the standard library is using contract assertions as defined in the core language (`pre`, `post`, and `contract_assert`) but that does not actually imply that those keywords are physically present in the standard library implementation, only that the standard library behaves as if they were there.
>>
>> In other words, if a standard library implementation internally uses macros — or some other implementation-defined mechanism — instead of the contextual keywords `pre`, `post`, and `contract_assert`, then that implementation is still conforming with that wording as long as the observable behaviour is the same as if those keywords were used —
>
> P2900 suggests that the contract semantics are selected by the one that is responsible for building the application, not the library writer.
> If the library uses a different tool that is not the contextual keywords, and thus allows different semantics for the library than for the application - is this within the "observable behaviour is the same as if those keywords were used"?

Assuming that by "library", you mean "standard library":

The mechanism for choosing the evaluation semantics of any particular evaluation of any assertion anywhere in the program is implementation-defined. It follows that allowing different contract-evaluation semantics for the standard library than for the rest of the program would be conforming. It follows further that offering one flag for choosing the contract-evaluation semantics of the standard library and a different flag for the contract-evaluation semantics of the rest of the program would be conforming too.

Does that answer your question?

Timur


Received on 2025-10-15 12:30:52