[EGCS 2.96, 2000/01/17 snapshot] Bad assembly code

Marco Goetze gomar@mindless.com
Tue Jan 18 03:22:00 GMT 2000


The attached file "bug.c" makes the compiler emit code erroneous in that

  bug.c:0: #define VAL (1<<7)
  bug.c:7: if (i & VAL) {

is compiled (via `gcc -S -g bug.c`) as

  bug.s:44: andl    $-128, %eax

which should be $128 (0xffffff80 vs. 0x00000080), since "(1<<7)" is a 
type int expression (-128 would have been the correct value if VAL was 
of type signed char).  Note: this also happened with the 2000/01/03
snapshot.

Attaching both "bug.c" and "bug.s".

  OS:             Linux 2.3.36
  compiler:       EGCS 2.96, 2000/01/17 snapshot
  compiler setup: native i586-pc-linux-gnu, configure switches:
                    --enable-shared --prefix=/usr
  glibc version:  2.1.2


More information about the Gcc-bugs mailing list