Skip to content

Commit

Permalink
Fix a clang optimization causing incorrect results for ST::string::fr…
Browse files Browse the repository at this point in the history
…om_int in Release builds
  • Loading branch information
zrax committed Mar 15, 2023
1 parent 565656e commit 7afa0a0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/st_string_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ namespace _ST_PRIVATE
{
typedef typename std::make_unsigned<int_T>::type uint_T;
ST::uint_formatter<uint_T> formatter;
formatter.format(std::abs(value), radix, upper_case);
uint_T abs_value = value < 0 ? -static_cast<uint_T>(value)
: static_cast<uint_T>(value);
formatter.format(abs_value, radix, upper_case);

ST::char_buffer result;
if (value < 0) {
Expand Down

0 comments on commit 7afa0a0

Please sign in to comment.