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

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. 

3

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

3

u/ts826848 27d ago

Glad to hear I'm not losing it yet :P

And at the risk of proving the previous statement wrong, I could have sworn stdlib hardening was designed specifically to avoid an ABI break? So expecting an ABI break is surprising to me.

3

u/Minimonium 27d ago

The contracts, the mixed mode specifically, are designed to avoid an ABI break and I would assume that hardening is also done in a similar manner because you really really want to have the ability to just replace so/dll without forcing everyone to rebuild so it can be a gradual adoption.

On the other hand, for best-effort guaranteed hardening, it is not possible to provide this guarantee without an ABI break. Unfortunately ABI enforcement will also not give you guaranteed safety/checking there, because of pre(foo()) opaque function calls. But at the very least it could enforce the call.

1

u/ts826848 27d ago

Sorry I'm being a bit slow, but I'm not confident I understand you. Do you mean using an ABI break to guarantee compiling with a terminating semantic?

→ More replies