On Mon, Mar 20, 2017 at 9:07 PM, Vladimir Batov via Boost
wrote: On 2017-03-20 22:13, Peter Dimov via Boost wrote:
... The analyzer is correct; passing char to isspace is a well-known bug, should be cast to unsigned char. The accepted range of the argument to isspace is -1..255 (assuming 8 bit character table), with -1 being EOF, and the default promotion from char to int doesn't do the right thing when char is signed.
Thanks, Peter, for clarifications. Clearly, the analyzer is correct. My interpretation was that it was the documented isspace() behavior. So, I felt somewhat uncomfortable "correcting"/changing the documented behavior. Now that you mention that it is a well-known bug to be (unfortunately) addressed I did just that. Thanks again. Much appreciated.
Damn confused.
WAS: std::isspace(ch);
THEN: std::isspace(static_cast<unsigned char>(ch));
THEN I realized I needed wchar_t support and therefore needed also
std::iswspace(). So, for such a seemingly trivial thing I ended up with
the following ugliness:
namespace cnv
{
template<typename char_type>
struct char_test {};
template<>
struct char_test<char>
{
static bool is_space(char ch)
{
return std::isspace(static_cast<unsigned char>(ch));
}
};
template<>
struct char_test