* [Bug c++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
@ 2022-11-12 3:49 ` redi at gcc dot gnu.org
2022-11-12 5:45 ` t3suzuki at ucsd dot edu
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-12 3:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-11-12
Ever confirmed|0 |1
Status|UNCONFIRMED |WAITING
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
As requested when creating the bug, please read https://gcc.gnu.org/bugs/ and
provide the missing information.
You're asking us to download and analyze a whole codebase we've never seen
before, which means your bug report will probably not get much attention.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
2022-11-12 3:49 ` [Bug c++/107660] " redi at gcc dot gnu.org
@ 2022-11-12 5:45 ` t3suzuki at ucsd dot edu
2022-11-12 5:57 ` t3suzuki at ucsd dot edu
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: t3suzuki at ucsd dot edu @ 2022-11-12 5:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #2 from Tomoya Suzuki <t3suzuki at ucsd dot edu> ---
I Sorry I didn't follow your bug report guidelines. After this, I investigated
the cause by myself, and it seems that there is a difference in the output of
the std::shuffle function. Even if the input and random number configurations
of the shuffle function are the same, can the output differ depending on the
gcc version?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
2022-11-12 3:49 ` [Bug c++/107660] " redi at gcc dot gnu.org
2022-11-12 5:45 ` t3suzuki at ucsd dot edu
@ 2022-11-12 5:57 ` t3suzuki at ucsd dot edu
2022-11-13 20:18 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: t3suzuki at ucsd dot edu @ 2022-11-12 5:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #3 from Tomoya Suzuki <t3suzuki at ucsd dot edu> ---
Perhaps I should ask the question in libc instead of gcc?
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (2 preceding siblings ...)
2022-11-12 5:57 ` t3suzuki at ucsd dot edu
@ 2022-11-13 20:18 ` pinskia at gcc dot gnu.org
2022-11-13 20:21 ` [Bug libstdc++/107660] " pinskia at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-13 20:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
std::mt19937
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (3 preceding siblings ...)
2022-11-13 20:18 ` pinskia at gcc dot gnu.org
@ 2022-11-13 20:21 ` pinskia at gcc dot gnu.org
2022-11-15 1:47 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-13 20:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> std::mt19937
r11-4535-g822c1d21a3c710
Hmm, this might be expected ....
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (4 preceding siblings ...)
2022-11-13 20:21 ` [Bug libstdc++/107660] " pinskia at gcc dot gnu.org
@ 2022-11-15 1:47 ` redi at gcc dot gnu.org
2022-11-15 17:50 ` t3suzuki at ucsd dot edu
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-15 1:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It's expected and required by the standard that std::mt19937 produces the same
numbers every time. And if I run a test for GCC 10 and GCC 11 I see the same
number produced for the first 2.14 billion results.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (5 preceding siblings ...)
2022-11-15 1:47 ` redi at gcc dot gnu.org
@ 2022-11-15 17:50 ` t3suzuki at ucsd dot edu
2022-11-15 19:24 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: t3suzuki at ucsd dot edu @ 2022-11-15 17:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #7 from Tomoya Suzuki <t3suzuki at ucsd dot edu> ---
The following code appears to me to work differently with gcc10 and gcc11.
#include <vector>
#include <algorithm>
#include <random>
int kRandSeed = 27491095;
int
main()
{
const int n = 16384;
std::vector<int> v(n);
std::mt19937 rng(kRandSeed);
//std::minstd_rand rng;
for (int i=0; i < n; i++)
v[i] = i;
std::shuffle(v.begin(), v.end(), rng);
for (int i=0; i < n; i++)
printf("%d\n", v[i]);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (6 preceding siblings ...)
2022-11-15 17:50 ` t3suzuki at ucsd dot edu
@ 2022-11-15 19:24 ` redi at gcc dot gnu.org
2022-11-16 1:41 ` t3suzuki at ucsd dot edu
2022-11-16 12:33 ` redi at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-15 19:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |UNCONFIRMED
Ever confirmed|1 |0
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Thanks for the reduced example code, I can see what the problem is now.
The mt19937 engine produces consistent results, but the commit that Andrew
linked to alters the output of std::uniform_int_distribution, due to a
different (much faster) algorithm used to downscale the random bits produced by
std::mt19937 to the number of elements being shuffled. The only requirement on
the uniform_int_distribution is that it produces values uniformly distributed
between the minimum and maximum values. Unlike std::mt19937 it doesn't have to
produce a specific sequence of values.
I supposed we could add a macro that disables the new fast implementation, for
users who prefer to get the same sequence of values as GCC 10, even though it's
slower.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (7 preceding siblings ...)
2022-11-15 19:24 ` redi at gcc dot gnu.org
@ 2022-11-16 1:41 ` t3suzuki at ucsd dot edu
2022-11-16 12:33 ` redi at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: t3suzuki at ucsd dot edu @ 2022-11-16 1:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
--- Comment #9 from Tomoya Suzuki <t3suzuki at ucsd dot edu> ---
Thanks for clarifying the cause. I don't think you need to add the macro just
for me, gcc11 behavior is not critical for me.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libstdc++/107660] Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier
2022-11-12 3:28 [Bug c++/107660] New: Running binaries compiled with g++11 or later produces different results than g++ version 10 or earlier t3suzuki at ucsd dot edu
` (8 preceding siblings ...)
2022-11-16 1:41 ` t3suzuki at ucsd dot edu
@ 2022-11-16 12:33 ` redi at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-16 12:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107660
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |WONTFIX
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
OK, thanks for clarifying. Let's close this as WONTFIX then, but I might
revisit it in future if others need stable results from the distribution.
^ permalink raw reply [flat|nested] 11+ messages in thread