3 ms·
> Nothing in POSIX mandates that isalnum has to be implemented using UB. That is a misunderstanding on your part. Calling isalnum with out-of-range values is U
by masklinn 5y ago
> Nothing in POSIX mandates that isalnum has to be implemented using UB.
That is a misunderstanding on your part. Calling isalnum with out-of-range values is UB. Per-spec: "If the argument has any other value, the behavior is undefined.".
> It is entirely permissible to return 0 for values out of range. Or -1. Or anything else.
Of course it is, it's UB, there's nothing it can't do.
> POSIX is not part of the C language, if a function's behaviour is not defined for a given input, that's not UB
So a behaviour which is not defined is not an undefined behaviour. Sure. Whatever.
> that's a license for the implementation to do whatever is natural. Which can be crashing embarrassingly, but why would you do that.
Why wouldn't you? A table-based implementation is flexible, convenient and efficient, and you don't care what happens outside of the function's bounds.