r/cpp • WG21 Member • Oct 24 '26

Balloting has completed for C++26. Unfortunately it was Disapproved

https://www.linkedin.com/posts/robertseacord_balloting-has-completed-for-c26-unfortunately-share-7519795139859517440-AOth/

Since the C++26 DIS has been disapproved, the next step is going to be taken in Buzios during the 2026-11 meeting. The committee will have to decide what changes to make (if any) and submit an FDIS (Final Draft of International Standard) for Balloting.

289 Upvotes

399 comments sorted by

View all comments

Show parent comment

7

u/Minimonium Oct 24 '26

I used "best effort" not as a coy way to walk around a sharp issue, but as a reflection of a range of behaviours we require for the feature to have even before going into the "mixed mode" topic.

What is "best effort" when we use NDEBUG with macro or ignore with Contracts?

A looks at the crash and finds a an invalid state that should have been caught by contracts way before the crash happened.

Seems like a false premise. Replace "contracts" with "asserts" here, with the same scenario. Keep in mind that what Developer A does in your case is a required behavior for cases where instrumented runs are simply impossible.

5

u/James20k P2005R0 Oct 25 '26

What is "best effort" when we use NDEBUG with macro or ignore with Contracts?

With asserts at least, you can in-source force your asserts to either be always-enabled or always-disabled, and fully disable external configurability of them if you have code which you think is going to be misused, or if you have asserts that must always be run. There's no equivalent to this for contracts unfortunately

This is one of the major reasons why there's objections to the current enforcement mode configurability of contracts (and why mandatory contracts would fix some problems for me at least), because unlike with asserts, there's no way to avoid the linking problems by enforcing a uniform configuration in-source

6

u/Minimonium Oct 25 '26

Hardened implementations are already guaranteed to only have terminating semantics that fixes all certified industry concerns to me. Adding separate syntax for specific semantics is additive work that certainly needs implementation experience to see if it's actually useful first, for example today we do not have a reason to have "always-disabled" pre/post conditions as we do not have a static analyzer yet that takes advantage of it.

I disagree that an in-source configuration would help here. Source is just source, and when you do not take control of downstream builds they may do all sorts of shenanigans with it and still try to link to your binaries.

Funny enough each time I read another "brilliant" idea to add configuration in-source (like the so-called "profile framework"), I remember the days when people used to "auto-link" dlls in-source in headers, with ifdef to link to d-suffixed binary variants. What a shit thing it was and how much effort it took to tear it out back in the days and build a proper build infrastructure.

6

u/Dragdu Oct 25 '26

Not for inline functions, which is the thing discussed here. If your inline function with assert gets emitted in a NDEBUG TU, whether the resulting unified function asserts or not is linker & link order dependent.

4

u/James20k P2005R0 Oct 25 '26

You can control the state of NDEBUG in source manually though, eg if you manage it in a header you can force your asserts to be always on regardless of what the build system says

2

u/Minimonium Oct 25 '26

The build system can... just patch it?

2

u/James20k P2005R0 Oct 25 '26

If I write

#undef NDEBUG
#include <assert.h>

The build system can't patch that

1

u/Minimonium Oct 25 '26

Your example is actually the most trivial to hijack (just supplant the header), you could make a better example with undef just before the usage but it can be patched as well.

2

u/James20k P2005R0 Oct 25 '26

Sure, but you don't generally try to defend against a malicious compilation of your code though IMO

Edit:

Or at least, you shouldn't be surprised when doing this breaks something very badly

3

u/Minimonium Oct 25 '26

It is not necessary a malicious compilation - source patching, while undesirable, is extremely common in package management because some poorly maintained projects encode build-level configuration (like NDEBUG here) in their source or build script code effectively and unexpectedly breaking their downstream consumers.