Current-Users archive

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

Re: isspace() behaviour



On Sun, Dec 15, 2024 at 08:34:35PM +0000, Patrick Welche wrote:
> int main()
> {
>         printf("%d", isspace(0xffffffffu));
> 
>         return 0;
> }
> 
> causes a segmentation fault on NetBSD-current/amd64, but returns 0 on
> ubuntu 24. One could say "don't do that, 0xffffffffu isn't a valid char".

Is that actual usage in the code or something whipped up to demonstrate
the issue?

> (That value was used in the program as "an EOF occured when that char
> was read".)

"an EOF occured when that char was read" leaves me stumped.
Clearly, if you are able to read a char, you weren't at EOF and if you
were at EOF you wouldn't be able to read a char.  That's how Unix has
worked forever.

--chris


Home | Main Index | Thread Index | Old Index