This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: New gcc 4.0.0 warnings seem spurious
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Bruce Lilly <blilly at erols dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 26 Apr 2005 15:10:44 +0000 (UTC)
- Subject: Re: New gcc 4.0.0 warnings seem spurious
- References: <200504261045.58422.blilly@erols.com>
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)