Skip to content

Commit 1fb4f9d

Browse files
himself65targos
authored andcommitted
src: fix warnings on SPrintF
PR-URL: #32558 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 6d12242 commit 1fb4f9d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/debug_utils-inl.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ struct ToStringHelper {
3030
template <unsigned BASE_BITS,
3131
typename T,
3232
typename std::enable_if<std::is_integral<T>::value, int>::type = 0>
33-
static std::string BaseConvert(T value) {
33+
static std::string BaseConvert(const T& value) {
34+
auto v = static_cast<uint64_t>(value);
3435
char ret[3 * sizeof(T)];
3536
char* ptr = ret + 3 * sizeof(T) - 1;
3637
*ptr = '\0';
3738
const char* digits = "0123456789abcdef";
3839
do {
39-
unsigned digit = value & ((1 << BASE_BITS) - 1);
40+
unsigned digit = v & ((1 << BASE_BITS) - 1);
4041
*--ptr =
4142
(BASE_BITS < 4 ? static_cast<char>('0' + digit) : digits[digit]);
42-
} while ((value >>= BASE_BITS) != 0);
43+
} while ((v >>= BASE_BITS) != 0);
4344
return ptr;
4445
}
4546
template <unsigned BASE_BITS,
@@ -56,8 +57,8 @@ std::string ToString(const T& value) {
5657
}
5758

5859
template <unsigned BASE_BITS, typename T>
59-
std::string ToBaseString(T&& value) {
60-
return ToStringHelper::BaseConvert<BASE_BITS>(std::forward<T>(value));
60+
std::string ToBaseString(const T& value) {
61+
return ToStringHelper::BaseConvert<BASE_BITS>(value);
6162
}
6263

6364
inline std::string SPrintFImpl(const char* format) {

0 commit comments

Comments
 (0)