Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::tolower(-5) #9

Open
OlafvdSpek opened this issue Mar 22, 2017 · 2 comments
Open

std::tolower(-5) #9

OlafvdSpek opened this issue Mar 22, 2017 · 2 comments

Comments

@OlafvdSpek
Copy link

I think this is undefined behavior.. tolower requires 'unsigned' input.

boost\algorithm\string\detail\case_conv.hpp:
return std::tolower<CharT>( Ch, *m_Loc );

std::string s(5, -5); // 5x char(-5)
boost::to_lower(s);
@mclow
Copy link
Owner

mclow commented Mar 22, 2017

Old STLs did require this - and there's workarounds there for them:

#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL)
    return std::tolower( static_cast<typename boost::make_unsigned <CharT>::type> ( Ch ));
#else
    return std::tolower<CharT>( Ch, *m_Loc );
#endif

I believe that this eventually winds its way down to ctype<char>::do_tolower(char), which has no such restrictions (at least not in c++11/14/17)

@OlafvdSpek
Copy link
Author

My bad, I confused std::tolower() with std::tolower()

BTW, are those Borland compilers still supported?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants