You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::string buffer::get_line(bool skip_whitespace) {
...
if (skip_whitespace) {
auto count = mismatch([](char chr) { return !std::isspace(chr); }); // <--
if (count == -1) {
position(limit()); // the end of the buffer has been reached
} else {
position(position() + count);
}
}
return tmp;
}
char can be signed on some C++ implementations, and have negative values.
Issue was hit, when parsing world mesh in steam-eng version of gothic2
The text was updated successfully, but these errors were encountered:
Hm interesting. To my knowledge isspace is supposed to take an int anyways (see cppreference)? Regardless I'll see if I can reproduce on MinGW on Linux so that I can actually see what's going on here :)
Update: I missed the most crucial part
The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.
Before, `std::isspace` was passed regular, possibly signed `char`s.
This is not supported by `std::isspace`, however, and causes incorrect
behaviour on some systems. As per cppreference:
> The behavior [of `std::isspace`] is undefined if the value of ch
> is not representable as unsigned char and is not equal to EOF.
-> see https://en.cppreference.com/w/cpp/string/byte/isspace
Before, `std::isspace` was passed regular, possibly signed `char`s.
This is not supported by `std::isspace`, however, and causes incorrect
behaviour on some systems. As per cppreference:
> The behavior [of `std::isspace`] is undefined if the value of ch
> is not representable as unsigned char and is not equal to EOF.
-> see https://en.cppreference.com/w/cpp/string/byte/isspace
(cherry picked from commit 69cd380)
sorry for awful screenshot :)
Offended code:
char
can be signed on some C++ implementations, and have negative values.Issue was hit, when parsing world mesh in steam-eng version of gothic2
The text was updated successfully, but these errors were encountered: