------- Comment #5 from manu at gcc dot gnu dot org 2008-08-22 13:53 ------- This is the current situation as of revision 139373.
typedef unsigned short ushort; enum { FOO = 0x13 }; template <typename T> inline void andnot(T& lv, const T& rv) { lv &= ~rv; // -Wconversion int(lv) & ~(int(rv)) } int main(int, char*[]) { ushort x = 99; x = ~FOO; // -Wsign-conversion -20 -> unsigned short x &= ~FOO; // -Wconversion int(x) & ~(int(19)) -> unsigned short x = x & ~FOO; // -Wconversion int(x) & ~(int(19)) -> unsigned short x = x & ushort(~FOO); // no warning x = x & ushort(~ushort(FOO)); // no warning x &= static_cast<ushort>(~FOO); // no warning x &= ~x; // no warning andnot(x, ushort(FOO)); // instantiated from here return x; } I don't see what is wrong with the warnings. Would you mind elaborating? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35852