nonportable code or incorrect compilers?

Ian H. Merritt ihm at nrcvax.UUCP
Fri Jul 29 05:35:25 AEST 1988


david at 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



More information about the Comp.std.c mailing list