This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc bug
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: gcc bug
- From: Pawel Palucha <pp174750 at zodiac dot mimuw dot edu dot pl>
- Date: Mon, 6 Mar 2000 10:36:04 +0100 (CET)
To: egcs-bugs@egcs.cygnus.com
From: Pawel Palucha (pawel.palucha@students.mimuw.edu.pl)
gcc version: egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
The same was with the gcc version 2.95.1 19990816.
This is the C-code that I think is not compiling well:
#include <stdio.h>
int main(void)
{
int i;
i = 32;
printf("%lu = %lu\n", 1UL << 32,
1UL << i );
return 0;
}
I compiled it to "a.out" just by typing "gcc proba.c".
The output from this program was:
0 = 1
Perhaps I'm wrong, but I though that "unsigned long k = 1UL << 32" is the
same as "int i = 32; unsigned long k = 1UL << i".
Type of i and k is not significant - the results are the same for
signed and unsigned.
Of course, I didn't ecounter this problem originaly in "proba.c" program -
it's just the illustration of problem with other, more complicated program.
During the compilation the warning "left shift count >= width of type" was
displayed, but only once - for the line with "1UL << 32".
This is what I got when I typed "gcc -S proba.c":
.file "proba.c"
.version "01.01"
gcc2_compiled.:
.section .rodata
.LC0:
.string "%lu = %lu\n"
.text
.align 4
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
movl $32,-4(%ebp)
movl $1,%eax
movl -4(%ebp),%ecx
sall %cl,%eax
pushl %eax
pushl $0
pushl $.LC0
call printf
addl $12,%esp
xorl %eax,%eax
jmp .L1
.p2align 4,,7
.L1:
leave
ret
.Lfe1:
.size main,.Lfe1-main
.ident "GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)"
My machine is PC with AMD K6-2 333MHz processor, 32 MB RAM, Award BIOS.
Operating system: Linux (Red Hat 6.1), kernel version 2.2.12-20.
gcc was installed from Red Hat rpm file.
Pawel Palucha