aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-02-27 12:50:53 +0000
committerJonathan Wakely <jwakely@redhat.com>2021-02-27 12:53:15 +0000
commit699672d4dccfb5579dbe48977bda86f6836225a0 (patch)
tree00e0b091a5855c0ef0c9d89bb65a3d368ed92bd7
parent652623f7c68594b1825a333bf8e83e87d1c3f523 (diff)
downloadgcc-699672d4dccfb5579dbe48977bda86f6836225a0.zip
gcc-699672d4dccfb5579dbe48977bda86f6836225a0.tar.gz
gcc-699672d4dccfb5579dbe48977bda86f6836225a0.tar.bz2
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.
-rw-r--r--libstdc++-v3/include/std/chrono4
1 files changed, 2 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono
index fcdaee7..11729aa 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;