In P3460R0 [0], implementation experience for C++ contracts is listed as having been acquired for two of the three major C++ compilers, namely GCC and Clang/LLVM. That paper was published October, 2024. However, as of today, about 2 years later, the actual status of implementation experience is in my opinion negative and surprising, and the history is likewise concerning.
For GCC:
Ville Voutilainen was involved with implementation of contracts in GCC [1][2] , and Ville Voutilainen was and is listed as one of the authors of the main C++ contracts proposal, P2900R14 [3]. Yet, Ville Voutilainen later became a major critic of contracts as proposed in P2900R14, while still fixing bugs in the contracts implementation for GCC. I do not understand why this is not highlighhted more in online discussions.
Especially in the light of there being very basic bugs in the contracts implementation for GCC currently [4] [5] , that also points towards significant implementation difficulties and burdens on compiler vendors in practice regarding C++ contracts. (C++ is already a language that is difficult to implement a compiler for, and the presence of bugs this basic does not indicate that contracts would not significantly worsen an already bad situation. Hopefully that is not the case.)
This does not point towards GCC having a complete and robust implementation of contracts, despite the efforts of several competent and experienced compiler engineers working on it.
For Clang/LLVM:
The implementation status appears to be worse for Clang/LLVM than for GCC. I have found two major implementations:
- EricWF's / Eric Fiselier's contracts implementation [6] . This fork is available on godbolt.org, but last saw updates 9 months ago, and while Eric Fiselier claims on his personal home page that it is a "Production-ready implementation of C++26 Contracts for Clang" [10], there are significant indications that it is both incomplete and experimental and not at all production-ready, especially considering that it has very basic bugs, like one where the implementation thinks that 0 is not less than 5 [7] [8] . And some of those very basic bugs have been open for months or years.
- A pull request (from an officially experimental fork) to add contracts to Clang/LLVM, which last saw updates about two months ago [9] . It is not available on godbolt.org as far as I know, and the first pull request only covers a subset of functionality, for the sake of easier review, with later pull requests meant to add the rest of the implementation from the experimental fork.
Usage of contracts in the real world:
I have barely seen any usage and adoption of C++ contracts in the real world. Searching on GitHub yields few results, perhaps only 1 repository, TrenchBroom, that actually used contracts without hiding them behind a preprocessor macro. If you, the reader, know of any examples of public and practical usage of contracts, please mention them.
Questions:
Why have proponents of contracts not made it clear that there are indications that there are significant problems regarding the implementation of contracts in GCC and Clang/LLVM? In a proper technical discussion, proponents of a feature should give an accurate description and assessment of the implementation status and of any other relevant information, not only come with "positive" descriptions. As far as I can tell, [0] did not give a clear and accurate impression of the implementation status of contracts in GCC and Clang/LLVM, especially given the situation of implementation 2 years later. And [10] gives an even more inaccurate impression.
Why did Eric Fiselier make a claim of production-readiness for his fork, when that still, months or years later, does not seem to be the case at all?
Why is the poor implementation status of contracts for C++ not being discussed in programmer forums more clearly, on Reddit, on Hacker News, on lobste.rs, on Discord forums, etc.? Are there widespread and significant problems with genuinely open and clear communication across these forums? If so, a solution might be more forums that actually enable open and effective discussion of C++ language development and other topics in tech.
For better or worse the normal approach is to standardize a language feature, then an implementation comes in the mainline compilers. It is completely normal for implementations to slowly appear in the compiler releases over the next years.
Requiring mainline implementation before standardizing would require a higher bar for contracts than for any other language feature in the history of C++. Due to the lack of mainstream implementations (the first one in GCC was only released in April), it is this also not surprising that there is a lack of projects using the feature.
There is no concern about difficulty of implementation.
I disagree more or less with your whole reply. In particular, I do not understand why you claim "There is no concern about difficulty of implementation." when some of the bugs are very simple and are not for esoteric pieces of code, yet have been open for years, and also implementers like Ville Voutilainen became skeptical about P2900R14 contracts.
> C++ Contracts were implemented in GCC and Clang according to P2900, and
usage experience was gathered across large code bases.
P2900’s specification was clear and implementable
> The representatives of two compiler vendors — Microsoft and EDG — have objected to standardizing contract assertions as in P2900. The objections are not about implementability. The feature is fairly simple to implement in its minimal form (just type-check the conditions and otherwise ignore them).
The presence of bugs in the implementation doesn't mean it's difficult to implement. They also haven't been open for years, because the implementation doesn't exist for years in mainline GCC.
See also discussions at:
https://www.reddit.com/r/cpp/comments/1y1y10z/c26_is_done_ag...
https://www.reddit.com/r/programming/comments/1y258te/c26_is...
My personal concerns:
In P3460R0 [0], implementation experience for C++ contracts is listed as having been acquired for two of the three major C++ compilers, namely GCC and Clang/LLVM. That paper was published October, 2024. However, as of today, about 2 years later, the actual status of implementation experience is in my opinion negative and surprising, and the history is likewise concerning.
For GCC:
Ville Voutilainen was involved with implementation of contracts in GCC [1][2] , and Ville Voutilainen was and is listed as one of the authors of the main C++ contracts proposal, P2900R14 [3]. Yet, Ville Voutilainen later became a major critic of contracts as proposed in P2900R14, while still fixing bugs in the contracts implementation for GCC. I do not understand why this is not highlighhted more in online discussions.
Especially in the light of there being very basic bugs in the contracts implementation for GCC currently [4] [5] , that also points towards significant implementation difficulties and burdens on compiler vendors in practice regarding C++ contracts. (C++ is already a language that is difficult to implement a compiler for, and the presence of bugs this basic does not indicate that contracts would not significantly worsen an already bad situation. Hopefully that is not the case.)
This does not point towards GCC having a complete and robust implementation of contracts, despite the efforts of several competent and experienced compiler engineers working on it.
For Clang/LLVM:
The implementation status appears to be worse for Clang/LLVM than for GCC. I have found two major implementations: - EricWF's / Eric Fiselier's contracts implementation [6] . This fork is available on godbolt.org, but last saw updates 9 months ago, and while Eric Fiselier claims on his personal home page that it is a "Production-ready implementation of C++26 Contracts for Clang" [10], there are significant indications that it is both incomplete and experimental and not at all production-ready, especially considering that it has very basic bugs, like one where the implementation thinks that 0 is not less than 5 [7] [8] . And some of those very basic bugs have been open for months or years. - A pull request (from an officially experimental fork) to add contracts to Clang/LLVM, which last saw updates about two months ago [9] . It is not available on godbolt.org as far as I know, and the first pull request only covers a subset of functionality, for the sake of easier review, with later pull requests meant to add the rest of the implementation from the experimental fork.
Usage of contracts in the real world:
I have barely seen any usage and adoption of C++ contracts in the real world. Searching on GitHub yields few results, perhaps only 1 repository, TrenchBroom, that actually used contracts without hiding them behind a preprocessor macro. If you, the reader, know of any examples of public and practical usage of contracts, please mention them.
Questions:
Why have proponents of contracts not made it clear that there are indications that there are significant problems regarding the implementation of contracts in GCC and Clang/LLVM? In a proper technical discussion, proponents of a feature should give an accurate description and assessment of the implementation status and of any other relevant information, not only come with "positive" descriptions. As far as I can tell, [0] did not give a clear and accurate impression of the implementation status of contracts in GCC and Clang/LLVM, especially given the situation of implementation 2 years later. And [10] gives an even more inaccurate impression.
Why did Eric Fiselier make a claim of production-readiness for his fork, when that still, months or years later, does not seem to be the case at all?
Why is the poor implementation status of contracts for C++ not being discussed in programmer forums more clearly, on Reddit, on Hacker News, on lobste.rs, on Discord forums, etc.? Are there widespread and significant problems with genuinely open and clear communication across these forums? If so, a solution might be more forums that actually enable open and effective discussion of C++ language development and other topics in tech.
[0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p34...
[1]: https://github.com/villevoutilainen/gcc/tree/contracts-nonat...
[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119061
[3]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p29...
[4]: https://godbolt.org/z/zYP4sfenP
[5]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125403
[6]: https://github.com/efcs/llvm-project/tree/contracts-nightly
[7]: https://github.com/efcs/llvm-project/issues/4
[8]: https://godbolt.org/z/EEKcbao1P
[9]: https://github.com/llvm/llvm-project/pull/221139
[10]: https://efcs.ca/
For better or worse the normal approach is to standardize a language feature, then an implementation comes in the mainline compilers. It is completely normal for implementations to slowly appear in the compiler releases over the next years.
Requiring mainline implementation before standardizing would require a higher bar for contracts than for any other language feature in the history of C++. Due to the lack of mainstream implementations (the first one in GCC was only released in April), it is this also not surprising that there is a lack of projects using the feature.
There is no concern about difficulty of implementation.
> For better or for worth the normal
"Worth" should be "worse".
I disagree more or less with your whole reply. In particular, I do not understand why you claim "There is no concern about difficulty of implementation." when some of the bugs are very simple and are not for esoteric pieces of code, yet have been open for years, and also implementers like Ville Voutilainen became skeptical about P2900R14 contracts.
Well, I'm saying there is no concern about difficulty of implementation, because that's what the implementers are saying:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p34...
> C++ Contracts were implemented in GCC and Clang according to P2900, and usage experience was gathered across large code bases. P2900’s specification was clear and implementable
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p40...
> The representatives of two compiler vendors — Microsoft and EDG — have objected to standardizing contract assertions as in P2900. The objections are not about implementability. The feature is fairly simple to implement in its minimal form (just type-check the conditions and otherwise ignore them).
The presence of bugs in the implementation doesn't mean it's difficult to implement. They also haven't been open for years, because the implementation doesn't exist for years in mainline GCC.