Re: [cc65] warnings int/char copying?

From: Ullrich von Bassewitz <>
Date: 2005-07-28 10:59:25

On Thu, Jul 28, 2005 at 12:16:37AM +0200, Johan Kotlinski wrote:
> I can't say it's an error of the compiler, but it made me a bit
> curious about what the philosophy is about warning for stuff like
> this? When and when not...

In general it's difficult to do these warnings right, especially in case of a
compiler that doesn't build explicit expression trees (like cc65). The problem
is, that in C there are no real "char values" because characters are
immediately promoted to integers. This is the reason, why

        sizeof ('a') == sizeof (int)

Because of the default promotions, an assignment

        char a = 'a';

is actually an assignment of an integer to a char variable. It is easy to see
why a rule like "warn if an integer is assigned to a char variable" won't
work. The more problematic cases could be sorted out by looking at the exact
expression, but as said above, this is a bit difficult in cc65, and I don't
expect the results to be satisfactory.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jul 28 10:59:34 2005

This archive was generated by hypermail 2.1.8 : 2005-07-28 10:59:37 CEST