From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 23AEE38532C7; Mon, 28 Nov 2022 15:19:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23AEE38532C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669648756; bh=lOtf4IihikkhVklUf9EdVZOAhIs8d+TTHiosLhJ4EV8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QlFu1EytjcEkZbs9lEJb8/61SgaKQPiUe1NStdbvv5Z+A3Xq+F4wCpOh9ZtggW06F GsfGvDohNd31CkWURmFDkjfCUWRTPQKcWPbNhKNiT/MkBR0nyt7OjzqrBnG/KRg1N9 6yjIakuuqlDgy4nL/fyaHh00OV6zxW+qfqZUeGF8= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107466] [12/13 Regression] invalid -Wnarrowing error with std::subtract_with_carry_engine Date: Mon, 28 Nov 2022 15:19:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: diagnostic, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107466 --- Comment #6 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:a64775a0edd46980036b757041f0c065ed9f8d22 commit r13-4364-ga64775a0edd46980036b757041f0c065ed9f8d22 Author: Jonathan Wakely Date: Mon Nov 28 09:44:52 2022 +0000 libstdc++: Make 16-bit std::subtract_with_carry_engine work [PR107466] This implements the proposed resolution of LWG 3809, so that std::subtract_with_carry_engine can be used with a 16-bit result_type. Currently this produces a narrowing error when instantiating the std::linear_congruential_engine to create the initial state. It also truncates the default_seed constant when passing it as a result_type argument. Change the type of the constant to uint_least32_t and pass 0u when the default_seed should be used. libstdc++-v3/ChangeLog: PR libstdc++/107466 * include/bits/random.h (subtract_with_carry_engine): Use 32-bit type for default seed. Use 0u as default argument for subtract_with_carry_engine(result_type) constructor and seed(result_type) member function. * include/bits/random.tcc (subtract_with_carry_engine): Use 32-bit type for default seed and engine used for initial state. * testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc: New test.=