public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r11-7427] libstdc++: Fix conversions from date types to integers [PR 99301]
Date: Sat, 27 Feb 2021 12:53:32 +0000 (GMT)	[thread overview]
Message-ID: <20210227125332.49B1E3858039@sourceware.org> (raw)

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;


                 reply	other threads:[~2021-02-27 12:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210227125332.49B1E3858039@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).