Re: [cc65] cc65 bug (?)

From: Greg King <greg.king41verizon.net>
Date: 2007-07-26 06:46:42
From: "Dan"; on Wednesday, July 25, 2007; at 09:27 PM -0400
>
> --- Oliver Schmidt wrote:
>
> > The program
> > ---------------------------------------------
> > #include <stdio.h>
> >
> > short s = 1000;
> >
> > void foo(char c)
> > {
> >   s += c;
> > }
> >
> > void main(void)
> > {
> >   foo(-10);
> >
> >   printf("\n%d\n", s);
> > }
> > ---------------------------------------------
> > should print out 990, but compiled with a rather
> > recent cc65 snapshot,
> > it does print out 1246.
>
> Not a bug.  Use the -j option if you want signed chars.

Even better:  declare that parameter as "signed char c".  You always should
use "signed char" or "unsigned char" when you plan to put general numbers,
instead of text, into a byte variable.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jul 26 10:51:59 2007

This archive was generated by hypermail 2.1.8 : 2007-07-26 10:52:01 CEST