https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103699
--- Comment #10 from Petr <kobalicek.petr at gmail dot com> --- Well, the problem is, that when you compile it with "-fsanitize=undefined" - it won't report any undefined behavior, and the function would return the expected value. I even tried to make everything constexpr - and constexpr by definition should never involve undefined behavior, right? But GCC 11 compiles the code with constexpr, doesn't complain against undefined behavior, and again, returns the wrong value. What I miss here, from user perspective, is some kind of diagnostics. If you remove code that is provable to have effect on the code following it, why not to complain, at least in constexpr case?