RFR: 8332400: isspace argument should be a valid unsigned char

Thomas Stuefe stuefe at openjdk.org
Mon Jun 10 08:38:13 UTC 2024


On Mon, 10 Jun 2024 08:20:38 GMT, David Holmes <dholmes at 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


More information about the serviceability-dev mailing list