This is the mail archive of the gcc@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]

Re: New gcc 4.0.0 warnings seem spurious


On Tue, 26 Apr 2005, Bruce Lilly wrote:

> Demonstration code:
> --------------------------
> #define AAA 0x1U
> #define BBB 0x2U
> 
> struct foo {
>     unsigned int bar:8;
> };
> 
> struct foo foos[] = {
>     { ~(AAA) },
>     { ~(BBB) },
>     { ~(AAA|BBB) },
>     { ~(AAA&BBB) }
> };
> --------------------------
> 
> compiling with gcc 3.x produced no warnings, as expected (no problems as
> all values fit easily within the defined structure's bit field).

I don't see why you think the warnings are spurious.  ~(AAA), for example, 
is 4294967294, which being greater than 255 certainly does not fit within 
the type unsigned:8.  Previous GCC versions had a long-known bug whereby 
they did not diagnose this; that bug has been fixed in GCC 4.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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