From 6c6ebe374a2eeb4da9134012717e90f6e64c143d Mon Sep 17 00:00:00 2001 From: bogdasar1985 Date: Thu, 28 May 2020 19:13:55 +0500 Subject: [PATCH] fixing UB --- include/external/clara.hpp | 2 +- include/internal/catch_string_manip.cpp | 2 +- third_party/clara.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/external/clara.hpp b/include/external/clara.hpp index c7348bf9..a0836487 100644 --- a/include/external/clara.hpp +++ b/include/external/clara.hpp @@ -667,7 +667,7 @@ namespace detail { } inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { std::string srcLC = source; - std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast( std::tolower(c) ); } ); + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast( std::tolower(c) ); } ); if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") target = true; else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") diff --git a/include/internal/catch_string_manip.cpp b/include/internal/catch_string_manip.cpp index 65be34d0..accb3498 100644 --- a/include/internal/catch_string_manip.cpp +++ b/include/internal/catch_string_manip.cpp @@ -18,7 +18,7 @@ namespace Catch { namespace { char toLowerCh(char c) { - return static_cast( std::tolower( c ) ); + return static_cast( std::tolower( static_cast(c) ) ); } } diff --git a/third_party/clara.hpp b/third_party/clara.hpp index 9f4f1b2c..eb4c7275 100644 --- a/third_party/clara.hpp +++ b/third_party/clara.hpp @@ -667,7 +667,7 @@ namespace detail { } inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { std::string srcLC = source; - std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast( ::tolower(c) ); } ); + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast( ::tolower( c ) ); } ); if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") target = true; else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")