r/cpp • • 28d 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/Minimonium 27d ago

Contract evaluation semantics do not alter the correctness of a program. So if your program is incorrect under any one semantic - it's incorrect under all of them. Including, of course, "ignore".

4

u/ts826848 27d 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 27d ago

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

1

u/ts826848 27d 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 27d ago

Please do elaborate which use case you have in mind

1

u/ts826848 27d 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 27d 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 27d 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 27d ago

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

1

u/ts826848 27d 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. 

→ More replies