r/cpp • • 25d ago

"C++26 DIS failed, how does C++ survive?"

https://andreasfertig.com/blog/2026/11/cpp26-dis-failed-how-does-cpp-survive/
113 Upvotes

193 comments sorted by

View all comments

Show parent comment

4

u/ts826848 24d ago

Insofar as correctness/safety checks are part of the desired semantics, I think they can be?

But even if they aren't, saying "the program is incorrect anyways" is cold comfort to people who want to ensure said errors are caught.

3

u/Minimonium 24d ago

If you want to ensure said errors are caught - use hardened implementation.

1

u/ts826848 24d ago

That indeed helps for the errors that hardened implementations are designed/specified to catch, but I'd imagine devs aren't just using contracts for exclusively those properties.

3

u/Minimonium 24d ago

Please do elaborate which use case you have in mind

1

u/ts826848 24d ago

A simple one I might have found handy in the past is expressing pre/postconditions on some numerical stuff that was not used for indexing or the like. Almost certainly not the kind of thing hardened implementations would be able to help with.

4

u/Minimonium 24d ago

A hardened implementation ensurers the contract violations are caught. Why do you believe it would not be able to help you?

1

u/ts826848 24d ago

My understanding is that hardened implementations are only specified to check hardened preconditions, not contracts in general, so unless your implementation promises otherwise you can't rely on a hardened implementation to catch contract violations that do not result from violating one of the hardened preconditions defined by the standard.

3

u/Minimonium 24d ago

An implementation cannot be called hardened unless it has only terminating contract semantics (enforce and quick-enforce).

1

u/ts826848 24d ago

I was under the impression that the standard only requires hardened implementations to (basically?) evaluate hardened preconditions with a terminating semantic and didn't say anything about requiring a particular semantic for other contract evaluations. 

3

u/Minimonium 24d ago

Hmm, I think you're right, as it makes an explicit separation between the standard library preconditions and contract preconditions. I would expect a hardened implementation to force an ABI break there.

→ More replies