]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix narrowing conversion in year_month_day [PR 99265]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 25 Feb 2021 11:48:18 +0000 (11:48 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 25 Feb 2021 11:53:59 +0000 (11:53 +0000)
libstdc++-v3/ChangeLog:

PR libstdc++/99265
* include/std/chrono (year_month_day::_S_from_days): Cast long
to int explicitly.

libstdc++-v3/include/std/chrono

index feb2c2a1fad83ad3512b5478a55467048701995f..eef503af2746bbb765100383c8058d371065cadf 100644 (file)
@@ -2481,8 +2481,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const auto __m1 = __j ? __m0 - 12 : __m0;
       const auto __d1 = __d0 + 1;
 
-      return year_month_day{chrono::year{__y1 + __z2}, chrono::month{__m1},
-                           chrono::day{__d1}};
+      return year_month_day{chrono::year{static_cast<int>(__y1 + __z2)},
+                           chrono::month{__m1}, chrono::day{__d1}};
     }
 
     // Days since 1970/01/01.