[PATCH] Avoid warnings in <charconv>
Jonathan Wakely
jwakely@redhat.com
Fri Oct 11 15:30:00 GMT 2019
* include/bits/charconv.h (__to_chars_len): Avoid -Wsign-compare
warnings.
Tested x86_64-linux. Committed to trunk.
-------------- next part --------------
commit 0839fa95cf5775f0022b35cda01bb0d6c27ca08a
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Oct 11 16:10:24 2019 +0100
Avoid warnings in <charconv>
* include/bits/charconv.h (__to_chars_len): Avoid -Wsign-compare
warnings.
diff --git a/libstdc++-v3/include/bits/charconv.h b/libstdc++-v3/include/bits/charconv.h
index a5b6be567bc..7c0922fec21 100644
--- a/libstdc++-v3/include/bits/charconv.h
+++ b/libstdc++-v3/include/bits/charconv.h
@@ -50,16 +50,16 @@ namespace __detail
static_assert(is_unsigned<_Tp>::value, "implementation bug");
unsigned __n = 1;
- const int __b2 = __base * __base;
- const int __b3 = __b2 * __base;
- const int __b4 = __b3 * __base;
+ const unsigned __b2 = __base * __base;
+ const unsigned __b3 = __b2 * __base;
+ const unsigned long __b4 = __b3 * __base;
for (;;)
{
- if (__value < __base) return __n;
+ if (__value < (unsigned)__base) return __n;
if (__value < __b2) return __n + 1;
if (__value < __b3) return __n + 2;
if (__value < __b4) return __n + 3;
- __value /= (unsigned)__b4;
+ __value /= __b4;
__n += 4;
}
}
More information about the Gcc-patches
mailing list