From 88a6ff0b65b375fcf1c502b2de3f8f360ecff649 Mon Sep 17 00:00:00 2001 From: Ian Hattendorf Date: Sat, 28 Apr 2018 23:23:30 -0700 Subject: [PATCH] Cast to unsigned char when using std::isalnum std::isalnum expects an int in the range of unsigned char or -1 (EOF), otherwise it exhibits undefined behavior. Casting from char to unsigned char avoids this. MSVC warns about this when compiling with /analyze. --- include/internal/catch_test_case_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp index 9bf68912..46164221 100644 --- a/include/internal/catch_test_case_info.cpp +++ b/include/internal/catch_test_case_info.cpp @@ -37,7 +37,7 @@ namespace Catch { return TestCaseInfo::None; } bool isReservedTag( std::string const& tag ) { - return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] ); + return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast(tag[0]) ); } void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { CATCH_ENFORCE( !isReservedTag(tag),