Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!hplabs!sm.unisys.com!psivax!nrcvax!ihm From: ihm@nrcvax.UUCP (Ian H. Merritt) Newsgroups: comp.std.c Subject: Re: nonportable code or incorrect compilers? Message-ID: <1539@nrcvax.UUCP> Date: 28 Jul 88 19:35:25 GMT References: <133@daitc.ARPA> <430@uwovax.uwo.ca> <2973@geac.UUCP> Reply-To: ihm@minnie.UUCP (Ian Merritt) Organization: The Frobboz Magic Compiler Co., Inc. Lines: 34 david@geac.UUCP (David Haynes) says: . . . >>> Which brings me to the question: is this code non-portable, or do >>> three out of four compilers surveyed fail to correctly implement K&R? >> >> Just to stir things up a little, under VAX/VMS, I get an answer >>of 839; Turbo C gives an answer of 840! > > >Now, if on the sun, I s/count *= DEFCONST/count = count * DEFCONST/ >I get the following: > >cc non-optimized count is 800, now 840 >cc optimized count is 800, now 840 > Microsoft C also produces the 840 result, suggesting that it's indeed a rounding issue whether you get 839 or 840, but from the above substitution, it sure looks like the sun compiler has a bug. Let's see now, compiled on my sun (SunOS 3.5 standard distribution), I get: cc non-optimized count is 800, now 840 cc optimized count is 800, now 840 Funny thing, but it's not happening here... I wonder when this was fixed... Incidentally, I got the same results on an IS68K bsd unix running very old software... -i