5 ms·
Safety profiles don't exist and there are so many issues with them that it's unlikely they will ever get added to the language. For example, you mention how it'
by Kranar 1y ago
Safety profiles don't exist and there are so many issues with them that it's unlikely they will ever get added to the language. For example, you mention how it's a method applied to a source file, but C++ doesn't have the concept of a source file, it only knows about translation units.
But then the problem becomes where exactly do you opt-in to this feature? If you do it in a header file then this can result in a function being compiled with the safety profile turned on in one translation unit and then that exact same function is compiled without that safety profile in another translation unit... which ironically results in one of the most dangerous possible outcomes in C++, the so-called ODR violation.
If you don't allow safety-profiles to be turned on in header files, then you've now excluded a significant amount of code in the form of templates, constexpr and inline functions.
- wffurr 1y agoThere's a new attempt at safety profiles. I'm not enough of an expert or read in enough on this proposal to answer your detailed questions, but there's a lot of words by Sutter and Stroustrop on the proposals: Stroustrop, 2023 presentation: https://open-std.org/JTC1/SC22/WG21/docs/papers/2023/p2816r0.pdf https://open-std.org/JTC1/SC22/WG21/docs/papers/2023/p2816r0... Sutter, 2025 committee paper: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3081r1.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p30... Sutter, 2024 blog post: https://herbsutter.com/2024/03/11/safety-in-context/ https://herbsutter.com/2024/03/11/safety-in-context/