Dave Dodge <dodo...@dododge.net> wrote: (14/04/2009 21:18) >> Ok. Point taken about undefined behaviour. Is the "unsigned char *p" >> declaration enough though? > >Yes. Dereferencing a valid (unsigned char *) will produce an >(unsigned char), which by definition is safe to pass to isupper. > >> One mail suggested using "unsigned" at every subsequent use of the >> variable. > >That's because p was a (char *), and therefore *p was producing a >possibly-signed value. Casting the dereferenced value to (unsigned >char) is another way of ensuring isupper gets a usable value, but I >think simply changing p to an (unsigned char *) is cleaner. >
So do I. Thankyou. >BTW it's worth noting that casting from a signed integer to an >unsigned integer is a well-defined operation, but casting from >unsigned to signed is implementation-defined. > Sounds familiar. I think I read there were at least three standard ways to encode negative numbers. Though I think one of them (Two's complement: up from 0 to total/2-1, and down from total until you reach total/2), where 'total' is the full count of possible values available) strongly dominates the others. _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/tinycc-devel