Source-Changes archive

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

Re: CVS commit: src/lib



In article <20041027203617.GF5984%snowdrop.l8s.co.uk@localhost>,
David Laight <david%l8s.co.uk@localhost> wrote:
>> >Fix a load of international alphabet problems with isxxx() and toupper()
>> >Change isspace(*char_ptr) to isspace(*char_ptr & 0xff) so that the correct
>> >piece of memory is looked at for the bit mask.
>> >gcc optimises out the '& 0xff' (on i386 at least).
>> >Fixes problems found by gcc when the splurious (int) cast is removed
>> 
>> Why didn't you cast to (unsigned char) as is the current practice everywhere
>> else in the code?!?
>
>Because I want the compiler to check that the argument is an integral value.
>In particular isdigit((unsigned char)cp) is a likely typo...
>
>I did check that the i386 generated code is a movzb.
>So *cp & 0xff, *(unsigned char *)cp, and (unsigned char)*cp probably all
>generate the same object code undeg gcc.

Lint picks those up (and more). There is little point on forcing arithmetic
expression evaluation for the compiler to detect errors when a simple cast
will do. The fact that gcc/i386 optimizes this out is not a good reason to
do this, specially when it changes existing practice.

christos



Home | Main Index | Thread Index | Old Index