From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 715323857003; Thu, 25 Feb 2021 11:54:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 715323857003 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-7388] libstdc++: Fix narrowing conversion in year_month_day [PR 99265] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: 7244879b883cb3405bdd98f051d50a2f36394e79 X-Git-Newrev: 75c74a83acee3f51e6753b8159fa600fe2d86810 Message-Id: <20210225115413.715323857003@sourceware.org> Date: Thu, 25 Feb 2021 11:54:13 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Feb 2021 11:54:13 -0000 https://gcc.gnu.org/g:75c74a83acee3f51e6753b8159fa600fe2d86810 commit r11-7388-g75c74a83acee3f51e6753b8159fa600fe2d86810 Author: Jonathan Wakely Date: Thu Feb 25 11:48:18 2021 +0000 libstdc++: Fix narrowing conversion in year_month_day [PR 99265] libstdc++-v3/ChangeLog: PR libstdc++/99265 * include/std/chrono (year_month_day::_S_from_days): Cast long to int explicitly. 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 feb2c2a1fad..eef503af274 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -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(__y1 + __z2)}, + chrono::month{__m1}, chrono::day{__d1}}; } // Days since 1970/01/01.