Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request From: peter%crayfish@ucsd.edu (Peter Rowat) Newsgroups: comp.sys.sun Subject: Basic C bug Keywords: 386i Message-ID: <8903190423.AA04698@crayfish.ucsd.edu> Date: 21 Apr 89 02:12:03 GMT Sender: usenet@rice.edu Organization: Sun-Spots Lines: 27 Approved: Sun-Spots@rice.edu Original-Date: Sat, 18 Mar 89 20:23:14 PST X-Sun-Spots-Digest: Volume 7, Issue 232, message 12 of 21 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 ]]