C optimizer bug?
bh.atari%rand-relay at sri-unix.UUCP
bh.atari%rand-relay at sri-unix.UUCP
Wed Feb 15 01:21:00 AEST 1984
From: Brian Harvey <bh.atari at rand-relay>
The 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 at 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
More information about the Comp.unix.wizards
mailing list