This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
warning: right shift count >= width of type
- From: "Dave Korn" <dk at artimi dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Mon, 29 Nov 2004 16:18:43 -0000
- Subject: warning: right shift count >= width of type
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
.file "foo.c"
.text
.p2align 4,,15
.globl _bar
.def _bar; .scl 2; .type 32; .endef
_bar:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
movb $32, %cl
shrl %cl, %eax
popl %ebp
ret
dk@mace /test/shift-test>
-------------------------<snip!>-------------------------
Why isn't the shift operation optimised away and replaced with const_int
0?
cheers,
DaveK
--
Can't think of a witty .sigline today....