public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107466] [12 Regression] invalid -Wnarrowing error with std::subtract_with_carry_engine Date: Thu, 08 Feb 2024 21:28:50 +0000 [thread overview] Message-ID: <bug-107466-4-LTjikbYh2b@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107466-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107466 --- Comment #12 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>: https://gcc.gnu.org/g:f2af87b9705d5a7e37b65bf342146ff25f025e49 commit r12-10143-gf2af87b9705d5a7e37b65bf342146ff25f025e49 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Jan 11 15:09:12 2024 +0000 libstdc++: Fix non-portable results from 64-bit std::subtract_with_carry_engine [PR107466] I implemented the resolution of LWG 3809 in r13-4364-ga64775a0edd469 but it was recently noted in the MSVC STL github repo that the change causes possible truncation for 64-bit seeds. Whether the truncation occurs (and to what value) depends on the width of uint_least32_t which is not portable, so the output of the PRNG for 64-bit seed values is no longer the same as in C++20, and no longer portable across platforms. That new issue was filed as LWG 4014. I proposed a new change which reduces the seed by the LCG's modulus before the conversion to uint_least32_t. This ensures that 64-bit seed values are consistently reduced by the modulus before any truncation. This removes the platform-dependent behaviour and restores the old behaviour for std::subtract_with_carry_engine specializations using a 64-bit result type (such as std::ranlux48_base). libstdc++-v3/ChangeLog: PR libstdc++/107466 * include/bits/random.tcc (subtract_with_carry_engine::seed): Implement proposed resolution of LWG 4014. * testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line number. * testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc: Check for expected result of 64-bit engine with seed that doesn't fit in 32-bits. (cherry picked from commit c224dec0e7c88e7a95633023018cdcb6ee87c65f)
next prev parent reply other threads:[~2024-02-08 21:28 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-30 18:42 [Bug c++/107466] New: [12 Regression] invalid -Wnarrowing error littlefox+gcc-bugzilla@lf-net.org 2022-10-30 18:50 ` [Bug c++/107466] [12/13 Regression] invalid -Wnarrowing error with std::subtract_with_carry_engine pinskia at gcc dot gnu.org 2022-10-30 20:40 ` redi at gcc dot gnu.org 2022-10-31 17:40 ` littlefox+gcc-bugzilla@lf-net.org 2022-11-04 20:39 ` [Bug libstdc++/107466] " redi at gcc dot gnu.org 2022-11-05 10:26 ` rguenth at gcc dot gnu.org 2022-11-25 9:38 ` redi at gcc dot gnu.org 2022-11-28 15:19 ` cvs-commit at gcc dot gnu.org 2023-04-27 11:42 ` [Bug libstdc++/107466] [12 " rguenth at gcc dot gnu.org 2023-04-27 11:42 ` rguenth at gcc dot gnu.org 2023-04-27 14:43 ` cvs-commit at gcc dot gnu.org 2023-04-27 14:44 ` redi at gcc dot gnu.org 2024-01-11 13:34 ` redi at gcc dot gnu.org 2024-01-13 0:14 ` cvs-commit at gcc dot gnu.org 2024-02-08 15:51 ` cvs-commit at gcc dot gnu.org 2024-02-08 21:28 ` cvs-commit at gcc dot gnu.org [this message] 2024-02-08 21:42 ` redi at gcc dot gnu.org
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=bug-107466-4-LTjikbYh2b@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).