[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: at least 260 packages broken on arm, powerpc and s390 due to wrong assumption on char signedness

On 31-Dec-01, 19:42 (CST), Ganesan R <rganesan@myrealbox.com> wrote: 
> Another thing that puzzles me since this whole debate started. If you look
> at the declaration of ctype.h functions (isalpha family), they take a int as
> an argument.

The reason the argument for these is int is a relic of the dark ages,
aka K&R C. Before function prototypes, there was no way to pass a real
char (or short) to a function: such arguments were promoted to int.
(Likewise, float was promoted to double -- thus all the math.h functions
taking double args.)

I don't know that I agree about needing to pass them unsigned char,
though. The char->int conversion should be value preserving. If you pass
a negative value, then you are making a domain error, and deserve what
you get.


Reply to: