which of course is true (though gcc does not warn about it, as I guess that
it was intentionally written that way). However, while considering what to do
about it, I noticed that the output code pcc produces is not strictly correct..

it seems that the function merely returns its input; the equivalent output from gcc
(and what I would expect) is to return 0 since all the bits have been shifted out

in fact, pcc is shifting "count % maxbits" rather than "count" here, which also produces
incorrect result for larger shifts..

Description

The following code snippet (which construct I found in some GNU code)
unsigned int foo(unsigned int a)
{
return a << 31 << 1;
}
when compiled with pcc, produces a warning
foo.c, line 3: warning: shift larger than type
which of course is true (though gcc does not warn about it, as I guess that
it was intentionally written that way). However, while considering what to do
about it, I noticed that the output code pcc produces is not strictly correct..
.text
.align 4
.globl foo
.type foo,@function
foo:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
.L85:
.L87:
movl 8(%ebp),%eax
movl %eax,-4(%ebp)
jmp .L86
.L86:
movl -4(%ebp),%eax
leave
ret
.size foo,.-foo
.ident "PCC: pcc 1.1.0.DEVEL 20120910 for netbsd-i386"
it seems that the function merely returns its input; the equivalent output from gcc
(and what I would expect) is to return 0 since all the bits have been shifted out
in fact, pcc is shifting "count % maxbits" rather than "count" here, which also produces
incorrect result for larger shifts..