http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090
Bug ID: 60090 Summary: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: chengniansun at gmail dot com For the expression "(l ^ a) != b", gcc -O0 emits no warning, but gcc -O1 emits a warning "comparison of promoted ~unsigned with unsigned". After checking the gimple code, I found the optimization transforms the expression to a bitwise not expression. However, in a syntactic perspective, the warning message is confusing, given the fact that there is no '~' in this expression. $: cat s.c int fn1(unsigned char a, unsigned char b) { const unsigned l = 4294967295u; return (l ^ a) != b; } $: gcc-trunk -c -Wsign-compare s.c $: gcc-trunk -c -Wsign-compare s.c -O1 s.c: In function ‘fn1’: s.c:3:18: warning: comparison of promoted ~unsigned with unsigned [-Wsign-compare] return (l ^ a) != b; ^