Commit 9457b3de3a9906db78b2a14e71da4dbdc39cfdbd

Authored by Florin Iucha
Committed by jarro2783
1 parent 073dd3e6

Fix -Wconversion warnings with GCC9 (#214)

Showing 1 changed file with 2 additions and 2 deletions
include/cxxopts.hpp
... ... @@ -551,7 +551,7 @@ namespace cxxopts
551 551 // if we got to here, then `t` is a positive number that fits into
552 552 // `R`. So to avoid MSVC C4146, we first cast it to `R`.
553 553 // See https://github.com/jarro2783/cxxopts/issues/62 for more details.
554   - return -static_cast<R>(t-1)-1;
  554 + return static_cast<R>(-static_cast<R>(t-1)-1);
555 555 }
556 556  
557 557 template <typename R, typename T>
... ... @@ -611,7 +611,7 @@ namespace cxxopts
611 611 throw_or_mimic<argument_incorrect_type>(text);
612 612 }
613 613  
614   - US next = result * base + digit;
  614 + const US next = static_cast<US>(result * base + digit);
615 615 if (result > next)
616 616 {
617 617 throw_or_mimic<argument_incorrect_type>(text);
... ...