Given the following testcase: --------------------------------- unsigned char foo;
void test () { foo &= 65280; foo &= 65280L; foo &= 65280U; foo &= 0xff00; foo &= 0xff00L; foo &= 0xff00U; } --------------------------------- when compiling (gcc -c test.c) there will be warnings emited at first, second, fourth and fifth expressions but ont at the third and sixth: test3.c: In function 'test': test3.c:5: warning: overflow in implicit constant conversion test3.c:6: warning: overflow in implicit constant conversion test3.c:9: warning: overflow in implicit constant conversion test3.c:10: warning: overflow in implicit constant conversion In my opinion, it should either warn everywhere (overflow because rvalue has bits set outside of the range of a 'char'), or emit a different warning with something aboud rvalue signedness. Also, if you increment all constants by one (e.g. 65281 and 0xff01) all warnings will disappear. So the warning emited before is either incorrect and should be never emited in such cases, or should be emited always, but not just sometimes. -- Summary: Inconsistent (incorrect?) "overflow in implicit constant conversion" warning Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: anpaza at mail dot ru http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41138