r/cpp • • Oct 25 '26

C++ profiles for initialization and invalidation: WIP implementation prototypes already exist in GCC/Clang

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p4415r0.pdf

In this paper it can be seen some interesting profiles progress for prototypes in Gcc and Clang.

20 Upvotes

29 comments sorted by

View all comments

1

u/Tyler_Burger_777 Oct 25 '26

I agree that profiles feel like the only evolution-friendly path forward, especially compared to the "rewrite everything in Safe C++" approach.

The point about UB classification is particularly interesting from a performance perspective. In high-performance computing (like SIMD sorting or AVX-512 code), we often rely on specific behaviors that might technically fall under UB but work predictably on our target compilers (e.g., type punning, pointer arithmetic for alignment).

If the invalidation/initialization profiles are too strict, they might inadvertently block compiler optimizations that we depend on for performance. It would be crucial to ensure that enabling a profile doesn't degrade the generated code for hot loops. Have you (or the committee) looked into how these profiles interact with vectorization or aggressive inlining? That's usually where the biggest performance cliffs appear.

4

u/ts826848 Oct 25 '26

It would be crucial to ensure that enabling a profile doesn't degrade the generated code for hot loops. Have you (or the committee) looked into how these profiles interact with vectorization or aggressive inlining? That's usually where the biggest performance cliffs appear.

Presumably you'd just disable the profile for the offending code?

3

u/germandiago Oct 25 '26

In theory and as long as it is part of a profile rule, there should be a mechanism.

3

u/ts826848 Oct 25 '26

I think given the context of the conversation that would be a safe assumption to make.