Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!harpo!seismo!hao!hplabs!sri-unix!bh.atari@rand-relay From: bh.atari%rand-relay@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: C optimizer bug? Message-ID: <16773@sri-arpa.UUCP> Date: Tue, 14-Feb-84 10:21:00 EST Article-I.D.: sri-arpa.16773 Posted: Tue Feb 14 10:21:00 1984 Date-Received: Mon, 20-Feb-84 01:20:31 EST Lines: 95 From: Brian HarveyThe following was sent to me by one of our users. I haven't played with it myself, but was wondering whether this situation is familiar to anyone, and if there is a known fix. Please reply directly to bh.atari@rand-relay since I don't subscribe to u-w. Tnx. Script started on Tue Feb 14 05:57:54 1984 Warning: no access to tty; thus no job control in this shell... % % % cat bug.c /* ** this file compiles with different results depending on ** whether or not the c optimizer is used. */ main() { int i; i = ((int) 1.0) & 0xff; printf ("i = 0x%x\n", i); } % % % cc bug.c -o nobug % nobug i = 0x1 % cc -O bug.c -o bug % bug i = 0x80 % % % cc -S bug.c % t bug.s LL0: .data .text .align 1 .globl _main _main: .word L12 jbr L14 L15: .data .align 2 L16: .double 0d1.00000000000000000000e+00 .text cvtdl L16,r0 bicl2 $-256,r0 movl r0,-4(fp) .data 1 L18: .ascii "i = 0x%x\12\0" .text pushl -4(fp) pushl $L18 calls $2,_printf ret .set L12,0x0 L14: subl2 $4,sp jbr L15 .data % cc -O -S bug.c % cat bug.s .data .text LL0:.align 1 .globl _main .data .align 2 L16:.double 0d1.00000000000000000000e+00 .text .data 1 L18:.ascii "i = 0x%x\12\0" .text .set L12,0x0 .data .text _main:.word L12 subl2 $4,sp movzbl L16,-4(fp) pushl -4(fp) pushal L18 calls $2,_printf ret % script done on Tue Feb 14 06:00:31 1984