peter%crayfish@ucsd.edu (Peter Rowat) (04/21/89)
We're using a 386i, sunos4.0.0 The "cc" compiler produces ****WRONG****
code when you mix function calls and arithmetic expressions. The following
is perhaps the simplest example:
============================================================
double one() {return 1.0;}
main()
{ printf("Bug? %lf \n", one() / ( one() + 2.0)); }
============================================================
produces
=======================================================
Bug? Inf
=======================================================
The output should, of course, be:
=======================================================
Bug? 0.33333333
=======================================================
So,don't trust cc! The GNU C works perfectly (so far).
Peter Rowat.
[[ The example works correctly on a 3/60 running SunOS 4.0.1. Have you
tried it under 4.0.1? --wnl ]]michael@agricola.mit.edu (Michael J. Wargo) (05/06/89)
Peter, I tried compiling (cc bug.c -o bug) your piece of code on an RR250 running 4.0.1. The answer was "Bug? 0.333333". Guess having 4.0.1 helps. [[ In some ways it does, yes. In other ways.......no. --wnl ]] Mike Wargo michael@agricola.mit.edu