Skip to content

Commit 234907d

Browse files
authored
Merge pull request #380 from cppalliance/379
Fix useless cast from decimal
2 parents edd235e + f3884ce commit 234907d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

include/boost/int128/detail/int128_imp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3264,7 +3264,7 @@ BOOST_INT128_HOST_DEVICE constexpr int128_t operator%(const int128_t lhs, const
32643264
}
32653265
#else
32663266

3267-
const auto is_neg{static_cast<bool>(lhs < 0)};
3267+
const auto is_neg{lhs < 0};
32683268

32693269
int128_t remainder {};
32703270

include/boost/int128/detail/mini_from_chars.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ BOOST_INT128_HOST_DEVICE constexpr int from_chars_integer_impl(const char* first
183183
}
184184

185185
// Return the parsed value, adding the sign back if applicable
186-
// If we have overflowed then we do not return the result
186+
// If we have overflowed, then we do not return the result
187187
if (overflowed)
188188
{
189189
return EDOM;
@@ -201,7 +201,18 @@ BOOST_INT128_HOST_DEVICE constexpr int from_chars_integer_impl(const char* first
201201

202202
// This value will be negative to differentiate from errno values
203203
// since they are in the range of acceptable distances
204+
205+
// This cast is useless on 32-bit platforms
206+
#if defined(__GNUC__) && !defined(__clang__)
207+
# pragma GCC diagnostic push
208+
# pragma GCC diagnostic ignored "-Wuseless-cast"
209+
#endif
210+
204211
return static_cast<int>(first - next);
212+
213+
#if defined(__GNUC__) && !defined(__clang__)
214+
# pragma GCC diagnostic pop
215+
#endif
205216
}
206217
} // namespace impl
207218

0 commit comments

Comments
 (0)