warning: right shift count >= width of type
Nathan Sidwell
nathan@codesourcery.com
Mon Nov 29 16:33:00 GMT 2004
Dave Korn wrote:
>
> Afternoon all. Here's something that's piqued my curiosity; it's probably
> owing to some language-lawyerly issue, but it isn't obvious to me. This is
> on gcc-3.3.3, (cygwin variant, but that's probably not relevant):
>
> -------------------------<snip!>-------------------------
> dk@mace /test/shift-test> cat foo.c
>
> unsigned int bar (unsigned int baz)
> {
> unsigned int quux;
>
> quux = baz >> 32;
> return quux;
> }
>
> dk@mace /test/shift-test> gcc -S foo.c -O2 -o foo.s
> foo.c: In function `bar':
> foo.c:7: warning: right shift count >= width of type
> dk@mace /test/shift-test> cat foo.s
> Why isn't the shift operation optimised away and replaced with const_int
> 0?
It's _undefined_. Didn't you make some comment about what undefined
meant last week :)
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
More information about the Gcc
mailing list