Skip to content

Commit

Permalink
close #236 (Integer overflow warning detected by clang++)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele77 committed Apr 3, 2024
1 parent 3d7091e commit ee14ce0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Custom handler for wrong commands (issue [#223](https://github.com/daniele77/cli/issues/223))
- Parent menus does not chain (issue [#234](https://github.com/daniele77/cli/issues/234))
- Parent menu shortcut (issue [#233](https://github.com/daniele77/cli/issues/233))
- Integer overflow warning detected by clang++ (issue [#236](https://github.com/daniele77/cli/issues/236))

## [2.1.0] - 2023-06-29

Expand Down
3 changes: 2 additions & 1 deletion include/cli/detail/fromstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ inline T signed_from_string(std::string s)
{
s = s.substr(1);
const U val = unsigned_digits_from_string<U>(s);
if ( val > static_cast<U>( - std::numeric_limits<T>::min() ) )
const auto min = std::numeric_limits<T>::min(); // this to avoid overflow warnings
if ( val > static_cast<U>( - min ) )
throw bad_conversion();
return (- static_cast<T>(val));
}
Expand Down

0 comments on commit ee14ce0

Please sign in to comment.