C++26 is done (again)! — Trip report: November 2026 ISO C++ standards meeting (Búzios, Brazil)
12 points by olliej
12 points by olliej
As a non-C++ person, I am so confused about why
pre<std::contracts::controls::enforced>(x > 0)
And not just
pre(x > 0)
What is the use case for wanting a default mode where the contract isn’t guaranteed to be enforced?
It seems lots of very, very smart people have been thinking a lot about this, so there must be some reason or chain of reasons that lands the proposal in this “the default mode may or may not be enforced and there’s a sort of generics syntax where you can opt in to enforced contracts”, but as an outsider it seems super confusing
My objections to contracts, and to be honest a lot of C++ since C++17, begin and end with "it's too complicated", and I've been programming in C++ for more than ten years.
I can understand that people involved in standardization know more about this stuff than I do, but I also know more about how the products I work on work than my customers, and yet their perspectives still matter more than mine.
It seems lots of very, very smart people have been thinking a lot about this
A recurring problem in our times.
The reality is, they should have removed all this contract bloat from C++23. All this stuff is useless and makes the language even larger and harder to understand than it already is. Take it from someone who learned Eiffel from Bertrand Meyer and realized first-hand that contracts add little value over assertions if they cannot be proven at compile-time.
What is the use case for wanting a default mode where the contract isn’t guaranteed to be enforced?
isn't the default mode "the end user chooses what behaviour they want from the compile flags they pass"? with e.g. -fcontract-evaluation-semantic=...
I thought the problem was that those compiler flags don’t apply if you accidentally do anything UB, and that this was the big disagreement, and that this new thing would be like “the program will halt if this expression is not true, no matter what”
But now that you say it, it feels like that would be something you want as a compiler flag rather than a.. generic or whatever the syntax there is.
If this is just a way to do local overrides of the compiler flags, it seems it then doesn’t address the reason people voted down the first proposal.
It all feels very confusing, but I assume 90% of that is that I don’t know C++
I thought the problem was that those compiler flags don’t apply if you accidentally do anything UB
One of the complaints about contracts was more precisely around what is called "mixed mode", where (approximately speaking) the same contract on a specific kind of functions function is compiled multiple times with different flags. This is technically not UB, but the standard did not guarantee exactly which flag(s) would be in effect in the final binary.
More concretely, say you have pre(x > 0) on a function in a header file for some library you wrote. You want/need this to always be enforced so you specify the appropriate flag in your build files. If a downstream consumer decides to build against the same header and specify that contracts are to be ignored, under the right circumstances the linker may choose the version with ignored contract checks for use in your library, effectively stripping out the checks you specified.
This behavior was a sticking point to say the least, and at least one NB (Romania IIRC) explicitly said so. A paper proposing something like enforced was rejected before the first failed NB vote, but I guess the failure changed enough minds to get a similar change through this time.
it seems it then doesn’t address the reason people voted down the first proposal.
There were multiple objections to the first draft standard. This change (supposedly) resolves some of them. Others (like "remove contracts entirely") were considered but the committee decided that no changes were warranted.
well you just noticed the biggest problem with c++: it's design-by-committee. there are so many entities - corporates, individuals, organizations, each wanting something different. maybe someone's employer's coding guideline requires contracts to be ignorable by default, and now we all have to pay for it.
What is the use case for wanting a default mode where the contract isn’t guaranteed to be enforced?
I write C++ professionally, but have done a lot of Ada work on the side.
Ada has fantastic contract support, and you can enable/disable contracts on a per-module basis. Contracts can use slow checks but be in hot paths, so you can turn them off when shipping, but still have them there for documentation purposes and when running for debugging or development purposes. It's great to be able to look at only the spec for a module and know exactly what it lets you do from the pre/post aspects. Being able to use contracts with proofs in Ada's SPARK subset is just icing on the cake.
Unlike Ada, C++ doesn't let you natively put custom ranges on integers, or predicates on types. I'm quite excited at the prospect of having contracts in C++ to clarify more about what functions do, especially when dealing with libraries. C++ often uses assertions, but you can't see these hidden inside of libraries and assumptions are often not documented.
It seems to me the ISO C++ working groups are made of lots of people who want to shoehorn their favorite feature into an already bloated language, and on the other side, the objectors include the author of the language himself, Bjarne Stroustrup, and many of the major C++ compiler implementers, who are on the record saying the contracts feature is misbegotten and should be eliminated completely. Under the circumstances, the C++ committee's proposed course seems like the textbook definition of insanity, trying something again, with minimal changes, and expecting a different result.