[Bug c/14294] New: bogus warning
nathan at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Wed Feb 25 17:26:00 GMT 2004
struct a {unsigned b : 2;};
int foo (struct a *p) {return 2u < p->b + 1;}
int bar (struct a *p) {return 2u < (unsigned)p->b + 1;}
gcc -W -Wall gives
bitfield.c:2: warning: comparison between signed and unsigned
bitfield.c:3: warning: comparison between signed and unsigned
1) is it correct to promote an unsigned bitfield smaller than an int to
signed int? (I think so, but am not 100% sure)
2) (unsigned)p->b + 1, should have unsigned type, hence the 2nd warning is spurious
--
Summary: bogus warning
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nathan at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14294
More information about the Gcc-bugs
mailing list