https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89722
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Xavier from comment #0) > This does not seem to occur with gcc, nor with g++ <= 7. I implemented the warning for GCC 8. > I could not find a workaround. Stop using macros? template<typename T> constexpr size_t bitsizeof() { return sizeof(T) * CHAR_BIT; } template<typename T> T bitmask_nth(T n) { return (T)1 << (n & (bitsizeof<T>() - 1)); } template<typename T> T test_bit(T* bits, unsigned n) { return bits[n / bitsizeof<T>()] & bitmask_nth((T)n); } > Clearly I cannot remove the cast : for shifting 32 bits or more, we need to > be on a int64. You can either use std::remove_const_t<typeof(*bits)> to get the unqualified version of the type, or just use decltype as Andrew suggested. The warning seems correct, typeof(*d->tab) is const int64_t, and casting (const int64_t)1 is defined by the language to be the same as (int64_t)1 so the const is ignored.