Contracts are in C++26 despite disagreement over their value
- Reference: 1774945691
- News link: https://www.theregister.co.uk/2026/03/31/cplusplus26_approved/
- Source link:
The committee met in Croydon, London, and approved the standard on March 28. According to [1]Sutter's report , the next stage is that the final document will be prepared and sent for international approval. C++ generally ships a new standard every three years, and the committee also adopted the schedule for C++29, on which work has already started.
Contracts are one of the major features in C++26, Sutter said. Contracts are a means of setting preconditions and postconditions on function declarations, and adding assertion statements within functions. The feature is intended to help make C++ code safer and more reliable.
[2]
The [3]paper [PDF] describing Contracts for C++26 notes that "behind the attempts to add a Contracts feature to C++ is a long and storied history." Contracts were also part of the C++20 working draft but WG21 removed them in 2019 following major changes in the proposed design.
[4]
[5]
The C++26 proposal describes itself as the culmination of a plan to produce a minimum viable product for C++26. There are gaps, such as no support for contracts on virtual functions, though this is expected in a future version.
Sutter is an advocate for Contracts and [6]spoke at CppCon 2025, held in Aurora, Colorado, on the "joy of C++26 contracts."
[7]
That view is not shared by Stroustrup, who [8]said during a presentation last year on pitfalls in C++26 contracts that "it's claimed to be a minimal viable product. It's not minimal, it's not viable."
Stroustrup said he will recommend not using contracts in C++. "This is adding complexity in very obscure ways. It's changing the meaning of code depending on where it is... I worry a lot about the complexity, I worry about whether we can use it correctly."
[9]Linear moves sideways to agentic AI as CEO declares issue tracking dead
[10]JetBrains shifts to agentic dev with Central, retires pair programming
[11]Mozilla introduces cq, describing it as 'Stack Overflow for agents'
[12]Avalonia bolts Linux and WebAssembly onto .NET MAUI
Sutter noted that some "smart and respected ISO C++ committee members have sustained technical concerns about contracts." The vote to finalize the C++26 standard was not unanimous because of this, with 114 in favor, 12 opposed, and three abstaining. However, Sutter said "the ISO C++ committee still wants contracts, and so contracts have stayed in C++26."
C++26 also includes [13]compile-time reflection , allowing code to be inspected and generated without any runtime overhead. This differs from reflection in Java or C#, which works at runtime. Sutter called it "the most powerful new engine for expressing efficient abstractions that C++ has ever had."
Sutter also talked up memory safety improvements in C++, for example, by defining erroneous behavior for uninitialized reads. In C++, undefined behavior (UB) is a major cause of errors and vulnerabilities, so the committee has a goal to reduce it, and this is one example of that effort.
[14]
The C++26 standard library has been hardened and Sutter said that, when implemented at Google, it fixed more than a thousand bugs and "reduced the segfault rate across the production fleet by 30 percent."
Another big feature is std::execution , which [15]provides a framework for async execution, though Sutter warned that it is "harder to adopt" than most C++ features because of poor documentation and lack of full library support. ®
Get our [16]Tech Resources
[1] https://herbsutter.com/2026/03/29/c26-is-done-trip-report-march-2026-iso-c-standards-meeting-london-croydon-uk/
[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/devops&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2acubQBFAjqQUSR-JLUvJ9QAAAMw&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0
[3] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2900r14.pdf
[4] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/devops&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44acubQBFAjqQUSR-JLUvJ9QAAAMw&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[5] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/devops&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33acubQBFAjqQUSR-JLUvJ9QAAAMw&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[6] https://www.youtube.com/watch?v=oitYvDe4nps
[7] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/devops&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44acubQBFAjqQUSR-JLUvJ9QAAAMw&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0
[8] https://www.youtube.com/watch?v=tzXu5KZGMJk
[9] https://www.theregister.com/2026/03/26/linear_agent/
[10] https://www.theregister.com/2026/03/25/jetbrains_central/
[11] https://www.theregister.com/2026/03/24/mozilla_introduces_cq_stack_overflow/
[12] https://www.theregister.com/2026/03/23/maui_linux_avalonia/
[13] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r13.html
[14] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/devops&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33acubQBFAjqQUSR-JLUvJ9QAAAMw&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0
[15] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p2300r10.html
[16] https://whitepapers.theregister.com/
Re: "help make C++ code safer and more reliable"
> I thought Rust was supposed to be the solution for that.
Sure, in the same way that Java and .NET are.
Fragile and dangerous bindings layers unfortunately make it non-viable until they finally bite the bullet and bolt on a tiny C frontend to integrate with the actual computing platform.
Contracts, as used in Eiffel, or D, or Ada.
I cannot see how an attempt to have a formal approach to be specific on behavior for pieces of code can be a "bad thing".
You do not have to use it - but I can see some fields in where contracts are welcome!
Virtual functions
Lack of support for virtual functions makes this much less useful than if could be. Yeah, I know, I'm old fashioned and like my polymorphism.
I was (2 years retired) a very enthusiastic user of the assert macro with pretty much the same intent as this extension. Pre/post and inline predicates that should always hold. Absolutely invaluable in making your assumptions explicit and executable. "Don't call this function unless you can provide parameters in this shape". "After you call me I promise the following will hold".
Co-workers hated me for rubbing their noses in their laziness and stupidity. The number of times I've had a an email begging to be allowed to remove an assertion so that their code can "work". Some would just go ahead and remove an assertion as part of a PR without even bothering to ask. The entire concept of correctness seems to be lost on many programmers.
Problem of course is when the assertion turns out to be wrong or too strict and a case is discovered that brings everything to a screeching halt. The standard does seem to have considered that with ability to handle failures or ignore evaluation. Devil is in the details...
Stroustrup said ... I worry a lot about the complexity
as well he might.
C++ has become another "estabilished" church as byzantine as any actual faith or the rituals of Gormenghast.
Rookie C++ developer meets AI coding assistant should blaze new trails of heretofore undreamt of buggery.
As a previously noted Eiffel had this as foundational feature and is arguably a much simpler language than any C++ spec since the C++ ARM.
I presented my safety solution (C++/sys) at C++Online 2026 recently (https://cpponline.uk/session/2026/cpp-sys/)
Through this, there was lots of discussion about contracts. It is exciting but I am not too sure about their applicability just yet. The extra work required to benefit from them feels a little fussy and verbose. This might restrict their use when what we need is essentially full coverage within a codebase.
But it does give us the hooks required to automate some of it.
Play the ostrich
As I no longer have to look at other people's efforts, I shall happily continue to write C++ code using only the bits that I understand* and can draw out a quick low-level "what it looks like in memory" diagram.
Including a note on which loops can allocate memory (hint: not during any inner loops that are chewing numbers, looking at certain people whose insistence that four levels of nested templates and a few "auto" declarations are better than any typedef).
* which does still increase over time, although these days the time balance between reading about the latest "modern C++" versus getting the blinkies to actually do useful work within the constraints of the microcontroller tends towards the latter. Static reflection sounds interesting... scroll, scroll, past the list of document changes...
"help make C++ code safer and more reliable"
I thought Rust was supposed to be the solution for that.
Caveat : as far as I know, the only thing more powerful and compact than C++ is Assembly language - in both cases, you want someone who knows what the fuck he's doing.