public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7427] libstdc++: Fix conversions from date types to integers [PR 99301]
@ 2021-02-27 12:53 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-02-27 12:53 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:699672d4dccfb5579dbe48977bda86f6836225a0

commit r11-7427-g699672d4dccfb5579dbe48977bda86f6836225a0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sat Feb 27 12:50:53 2021 +0000

    libstdc++: Fix conversions from date types to integers [PR 99301]
    
    The conversions to integer types are explicit, so need to use the
    correct type. Converting to uint32_t only works if that is the same type
    as unsigned.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/99301
            * include/std/chrono (year_month_day::_M_days_since_epoch()):
            Convert chrono::month and chrono::day to unsigned before
            converting to uint32_t.

Diff:
---
 libstdc++-v3/include/std/chrono | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index fcdaee7328e..11729aae708 100644
--- a/libstdc++-v3/include/std/chrono
+++ b/libstdc++-v3/include/std/chrono
@@ -2496,8 +2496,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       auto constexpr __r2_e3 = static_cast<uint32_t>(536895458);
 
       const auto __y1 = static_cast<uint32_t>(static_cast<int>(_M_y)) - __z2;
-      const auto __m1 = static_cast<uint32_t>(_M_m);
-      const auto __d1 = static_cast<uint32_t>(_M_d);
+      const auto __m1 = static_cast<uint32_t>(static_cast<unsigned>(_M_m));
+      const auto __d1 = static_cast<uint32_t>(static_cast<unsigned>(_M_d));
 
       const auto __j  = static_cast<uint32_t>(__m1 < 3);
       const auto __y0 = __y1 - __j;


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

only message in thread, other threads:[~2021-02-27 12:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-27 12:53 [gcc r11-7427] libstdc++: Fix conversions from date types to integers [PR 99301] 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).