Skip to content

Commit

Permalink
Do proper handling of signed/unsigned types when parsing flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
peadar committed Aug 19, 2023
1 parent e041dab commit 8f0c0cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libpstack/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
namespace {
template <typename T> void convert(const char *opt, T &to) {
if constexpr (std::is_integral<T>::value)
to = strtol(opt, 0, 0);
if constexpr (std::is_signed<T>::value)
to = T(strtoll(opt, 0, 0));
else
to = T(strtoull(opt, 0, 0));

else if constexpr (std::is_floating_point<T>::value)
to = strtod(opt, 0);
else
Expand Down

0 comments on commit 8f0c0cf

Please sign in to comment.