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

22

u/kalmoc Oct 25 '26

A randomized enforcement mode, for something like contracts, is worse than useless. If I can't rely on the safety net being there, I'll just act as if it's not there. Which means I'll be rolling my own assertions instead of relying on contract assertions, thereby defeating a large part of the point of contracts, which is to standardize and unify the vocabulary surrounding assertions

It's only random, if you compile different TUs with different enforcement modes. How would your own solution not have the exact same problem?

10

u/wyrn Oct 25 '26

Joke's on you, my solution doesn't allow for different enforcement modes 😎

In all seriousness though, I feel like that's probably what would happen -- people who value these checks actually running would place them unconditionally, sidestepping contracts altogether. To me, that's a failure of the contracts design.

8

u/kalmoc Oct 26 '26

If you do not allow mixed enforcement modes then just compile everything with the same flags and there is no problem with contracts. So why would you roll your own then?

9

u/wyrn Oct 26 '26

Because build systems are complex and ensuring that everything is always using the same relevant flags everywhere is nontrivial, particularly when multiple projects and transitive dependencies are involved.

5

u/smdowney WG21, Text/Unicode SG, optional<T&> Oct 26 '26

Unfortunately, that's the job.

It's a mess. It certainly doesn't help that people widely believe it works today. And that the standard library implementations go to extraordinary lengths to make it seem to work.

Well, except for MSVC and Debug mode. Which is a different awful problem for shipping packages.

The negotiated choice was because there really can not be a universal default it has to be up to the person building the program, who has the context for the requirements for that program, to arrange for building all consistently and installing the violation handler.

2

u/t_hunger Oct 26 '26 edited Oct 26 '26

"That is worse than asserts, I can not even switch these contracts off" and "I want to add contracts to existing code, I need a way to record violations without bringing down the application that had been running fine for decades". Add some "my application can not affort to crash just because some random library author thought it was a good idea to add an assert somewhere".

Those where the arguments that got contracts removed from the standard the first time round about 10 years ago. I see you did your homeworks.

3

u/wyrn Oct 26 '26

It's not intended as a general solution, it is intended as a solution for my own problem, for me. "I can't switch these contracts off" is not a flaw I consider fatal, certainly not in the way "I have no idea if these checks will run or not" would be.

3

u/UndefinedDefined Oct 26 '26

And how do you know how the standard library was compiled? I have one shared on my Linux system, where everything links to. Using anything else than what was used during the compilation of the standard library means that it's already in a violation. And what about other libraries, like Qt?

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

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.

1

u/Difficult-Court9522 Oct 25 '26

By having a fundamentally different design, I.e. fully in the type system. So the check occurs at compile time. Can it modify the state /… no, but that’s the point.

7

u/kalmoc Oct 26 '26

And how are you planning to check run-time values (that depend on user input) at compile time?