Article View: comp.sys.dec
Article #1787Re: Compiler Bug
From: Dirk Grunwald
Date: Mon, 30 Jul 1990 16:29
Date: Mon, 30 Jul 1990 16:29
54 lines
2005 bytes
2005 bytes
>>>>> On 30 Jul 90 14:20:37 GMT, hudgens@sun13.scri.fsu.edu (Jim Hudgens) said:
JH> How about this one.
JH> Under Ultrix 4.0, we get this behavior:
JH> $ cat bug.c
JH> #include<stdio.h>
JH> main()
JH> {
JH> int d;
JH> double f;
JH> long l;
JH> int i;
JH> i = 4;
JH> f = 244.0;
JH> l = 2000;
JH> d = l * i/f;
JH> printf("%d * %d / %f = %d\n",
JH> l, i, f, d);
JH> }
--
this is program 'testb' in the following. Program 'testa' is the
previous one involving 'malloc'.
Using 'gcc' as done by meissner@osf.org, the following results. You
can pick up the tar file for building this (heavily modified) version
of 'gcc' from foobar.colorado.edu:pub/Gnu-For-Pmax. Be warned that
that 'gcc' -O3 and -O2 optimization produces code about 10-20% slower
than Mips 'cc' (1.31). I do not know how it compares to the mips 2.x
suite.
[foobar-81] gcc -o testa testa.c
[foobar-82] ./testa
-18
-18
[foobar-83] gcc -O -o testa testa.c
[foobar-84] ./testa
-18
-18
[foobar-85] gcc -o testa -O2 testa.c
[foobar-86] ./testa
-18
-18
[foobar-87] gcc -o testb testb.c
[foobar-88] ./testb
2000 * 4 / 244.000000 = 32
[foobar-89] gcc -o testb -O testb.c
[foobar-90] ./testb
2000 * 4 / 244.000000 = 32
[foobar-91] gcc -o testb -O2 testb.c
[foobar-92] ./testb
2000 * 4 / 244.000000 = 32
[foobar-93]
Technical Details
Message-ID:
<24118@boulder.Colorado.EDU>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!pacbell.com!ames!ncar!boulder!grunwaldReferences:
<3152@rwthinf.UUCP> <5889@crltrx.crl.dec.com> <327@sun13.scri.fsu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!ucsd!pacbell.com!ames!ncar!boulder!grunwald From: grunwald@foobar.colorado.edu (Dirk Grunwald) Newsgroups: comp.sys.dec Subject: Re: Compiler Bug Message-ID: <24118@boulder.Colorado.EDU> Date: 30 Jul 90 16:29:10 GMT References: <3152@rwthinf.UUCP> <5889@crltrx.crl.dec.com> <327@sun13.scri.fsu.edu> Sender: news@boulder.Colorado.EDU Reply-To: grunwald@foobar.colorado.edu Distribution: na Organization: University of Colorado at Boulder Lines: 54 In-reply-to: hudgens@sun13.scri.fsu.edu's message of 30 Jul 90 14:20:37 GMT