https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93589
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I don't see the issue here due to promotion rules in C++. Note your example code does not match the warning message you have in comment #0. Just add an extra cast: static_cast<T>((CHAR_BIT * static_cast<T>(i)) << (CHAR_BIT * static_cast<T>(i))) Will fix the warning. >This does not happen with CLANG. So what two different compilers, two different choices here :). Does clang warn even in a non-template case?