[Bug c/88895] unnecessary -Wshift-count-overflow in unreachable code (shift)

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jan 17 20:41:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88895

--- Comment #5 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #2)
> The warning is not specific to C++ but triggers for C code as well

True, but C++ templates somehow make this different. In C, you could use the
preprocessor to test for the size of int. In C++, expecting the compiler to
silently get rid of useless cases (like x<0 tests when the function is
instantiated with an unsigned type for x) is normal in templates.
Starting with C++17 you could use if constexpr, although the lack of switch
constexpr makes it less readable.


More information about the Gcc-bugs mailing list