atari email archive

a collection of messages sent at Atari from 1983 to 1992.

Yet another Greenhills Bug

(1 / 1)

	The following Greenhills C bug (version 1.8.0) caused a really obscure
bug in the stats package on XYBots.  I have kluged around it on all the stats
packages I "control", but those of you who are winging it on your own, or just
generally multiplying unsigned shorts occasionally, should watch out!

	The following code fragment:

unsigned int coins,time;
time = (unsigned short)time * 60;

produced the following assembly:

	MOVEQ	#0,D0
	MOVE.W	D3,D0	*fr
	MULS	#60,D0

note that it "knew" that D0 was unsigned, and that the constant 60 (which is
clearly positive) would fit in a short, but it used a MULS.

	Changing the second line to:

time = (unsigned short)time * (unsigned short)60;

fixes the problem (this time).
Message 1 of 1

Jan 08, 1988