From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-03-15 14:56:39
On Fri, Mar 15, 2002 at 02:14:26PM +0100, groepaz wrote: > when i took some code originally made with cc65 and compiled it using > gcc, it started behaving strange, and i could track down the error to > a line > > y2=((y1*c))-((z1*s))>>8; (notice the _wrong_ braces, this > worked like intended in cc65!!!) > > which should correctly look like > > y2=((y1*c)-(z1*s))>>8; > > ....so, the fact that it worked before implies that there maybe a bug > with the expression evaluation in cc65? any ideas? The C standard says that the binary minus operator has a higher precedence than the shift operator, so both expressions must evaluate identical, which in turn means that cc65 is doing the right thing. I cannot really believe that gcc has a problem in this area, because this is quite a basic thing, and gcc has a lot more users than cc65 (so the chance of a bug being detected is much higher than with cc65). Maybe something else is wrong with your code? Two ideas that come to mind: * Signedness problems: If any one of the variables used in the expression is actually a character, your code may behave strange on some platforms for values > 127, because characters may be signed data types. As a rule of thumb, you should always specify your characters as "signed" or "unsigned", if you use them as small numbers and not as actual characters. * Range problems: cc65 has 16 bit ints. So if your code relies on the fact that anything greater than 16 bit is silently dropped, it may not work well on most platforms supported by gcc, because on these platforms, ints are often 32 bits. Regards Uz -- Ullrich von Bassewitz uz_at_musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-03-15 14:56:41 CET