public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid warnings in <charconv>
@ 2019-10-11 15:29 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2019-10-11 15:29 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 119 bytes --]

	* include/bits/charconv.h (__to_chars_len): Avoid -Wsign-compare
	warnings.

Tested x86_64-linux. Committed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1182 bytes --]

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;
 	}
     }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-10-11 15:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-11 15:29 [PATCH] Avoid warnings in <charconv> Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).