On Mon, 10 Jun 2024 08:20:38 GMT, David Holmes <dhol...@openjdk.org> wrote:

> > "To use these functions safely with plain chars (or signed chars), the 
> > argument should first be converted to unsigned char"
> 
> @tstuefe wow! Okay. That is a surprise to me. A cast to unsigned char doesn't 
> actually do anything. Every char is "representable" as an unsigned char 
> because it holds a bit pattern between 0x00 and 0xff i.e. the function is 
> well defined if the incoming int is either EOF (int -1) or else in the range 
> 0x00 to 0xff. But I did a bit of searching and it seems it comes down to 
> potential arithmetic operations on the "char" the might behave differently 
> depending on the signed-ness. :(

I was surprised as well. Turns out you can use something for 20+ years and not 
notice :)

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19567#issuecomment-2157711653

Reply via email to