Date: Thu, 19 Feb 2026 16:27:51 +0100
Hi Jan,
On 2026-02-19T16:03:26+0100, Jan Schultke via Std-Proposals wrote:
> What OP proposes could also be done separately from static analysis as a
> compiler flag that requires the compiler to prove all contracts hold. This
> essentially turns contract_assert into OP's compile_assert when the
> semantic is ignore. In any case, I think contracts are the right way to
> express conditions that should hold.
I think contracts would have been less necessary with this feature.
And in C, we certainly don't want contracts, while this API would be
very nice.
You can implement "contracts" by wrapping functions in macros, and using
this API to enforce conditions.
That would be a trivial feature compared to contracts, would provide
more safety (if the contract can't be proven, it doesn't compile), and
could be read by someone learning C.
I strongly support this proposal, if it finds a way to specify the
wording in a good way. In fact, I hope it is also added to ISO C.
Cheers,
Alex
On 2026-02-19T16:03:26+0100, Jan Schultke via Std-Proposals wrote:
> What OP proposes could also be done separately from static analysis as a
> compiler flag that requires the compiler to prove all contracts hold. This
> essentially turns contract_assert into OP's compile_assert when the
> semantic is ignore. In any case, I think contracts are the right way to
> express conditions that should hold.
I think contracts would have been less necessary with this feature.
And in C, we certainly don't want contracts, while this API would be
very nice.
You can implement "contracts" by wrapping functions in macros, and using
this API to enforce conditions.
That would be a trivial feature compared to contracts, would provide
more safety (if the contract can't be proven, it doesn't compile), and
could be read by someone learning C.
I strongly support this proposal, if it finds a way to specify the
wording in a good way. In fact, I hope it is also added to ISO C.
Cheers,
Alex
-- <https://www.alejandro-colomar.es>
Received on 2026-02-19 15:28:00
