Bug 14294 - bogus warning
Summary: bogus warning
Status: RESOLVED DUPLICATE of bug 3325
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-25 17:26 UTC by Nathan Sidwell
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Sidwell 2004-02-25 17:26:40 UTC
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
Comment 1 Andrew Pinski 2004-02-25 17:28:31 UTC
This is a dup of bug 3325.

*** This bug has been marked as a duplicate of 3325 ***