flyingpast 2 hours ago
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/