Basic C bug
Peter Rowat
peter%crayfish at ucsd.edu
Fri Apr 21 12:12:03 AEST 1989
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 ]]
More information about the Comp.sys.sun
mailing list