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

2

u/kalmoc Oct 26 '26

Again: How would your solution better? If you roll your own, you don't get contracts in the standard library at all. And of course, every 3rd party library that you are using will again either roll their own, or have none. I don't see, how that is any better .

Profiles don't solve a thing, they bring new problems into the language. 

What have profiles to do with this?

0

u/UndefinedDefined Oct 26 '26

It doesn't matter, because most libs already have their own assert macros. And honestly, it's convenient, because you have category of asserts that are enable only during debug and have asserts that are also enabled during release. And users can tune these asserts when needed.

And how is that different? Asserts are in function bodies, not in header files, thus a recompile or change doesn't need to recompile a world if you want to debug a single library in your mono-repo. And macro-based asserts have additional benefit - you can only turn asserts in your code, but not mess with asserts in a third-party code. It's convenient, useful, and I don't see anything like this offered by profiles - to tune profiles per library, for example.

Another perspective is that usually, you cannot turn all asserts into pre/post conditions, because you would destroy the performance of your code. If you look how asserts are used, they guarantee against impossible, they are verbose and check much more than would be strictly necessary - and that's the main motivation to have many of them - they are only used in debug builds to enforce strict consistency model during testing.

Turn asserts on, recompile chromium, and watch for yourself.

4

u/kalmoc Oct 27 '26 edited Oct 27 '26

Again, this is about contracts and NOT profiles.

And the very fact that everyone is complaining about is that you CAN select different enforcement modes for different translation units in the same program.

Asserts are in function bodies, not in header files, 

You are aware that function bodies can also reside in headers right? 

And if you include a header with an inline function containing an assert macro into two translation units, where one has NDEBUG defined and the other hasn't (i.e. compiling the library, vs compiling the user of that library with different settings), you not only do not know, which version you get, you have an actual ODR violation and thus undefined behavior.

The contract proposal is in improvement over that situation, because at least you do not get undefined behavior.

Another perspective is that usually, you cannot turn all asserts into pre/post conditions

Yes, and for that reason, the contracts proposal also includes an assert feature and not just pre and Post conditions

0

u/UndefinedDefined Oct 27 '26

different enforcement modes for different translation units in the same program.

Different TUs - now imagine you have a header-only library, has its own assert macros, but you don't want these to be turned on, only yours. It's the same TU, unsolvable with contracts, because a contract is for TU, not for a library.

I cannot say I don't want enforcement for library A, but I want it for my own code.

You cannot replace macros. Everybody who tries to replace macros end up with something even worse than that.

-1

u/UndefinedDefined Oct 27 '26

Yes, and for that reason, the contracts proposal also includes an assert feature and not just pre and Post conditions

Of course - asserts will be with us to the world end, that's why it's completely useless trying to replace them. Just more bloat into the language.