This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/14294] New: bogus warning


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]