Hacker News new | ask | show | jobs
by AshamedCaptain 1168 days ago
This does not really "guarantee" anything. You can still have as much UB (incl leaks) as you want, as long as they are not evaluated at compile-time. i.e. it's at best equivalent to running valgrind.
1 comments

What would be examples of runtime UBs that wouldn’t be reported when used within a constexpr?
The point is that the code is only checked for UB with the arguments it is given at compile time. There is no guarantee that it can't invoke UB with other arguments it might receive at runtime.

For example, here is a modification of the original program that does invoke UB, but compiles just fine:

https://godbolt.org/z/MaqhcEYqn

Oh yes, I see your point. Thanks for clarifying