Hacker News new | ask | show | jobs
by dgellow 1167 days ago
What would be examples of runtime UBs that wouldn’t be reported when used within a constexpr?
1 comments

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