Created attachment 18991
linear_congruential_engine test
To my understanding the C++ standard does not mandate the algorithms for random
number distributions but it does mandate the algorithms for random number
generators like linear_congruential_engine. So one should be able to generate
consistent random values across all platforms/compilers.
However, i stumbled upon inconsistent values between various compilers and
verified this observation with online compilers. I am not sure which compiler
is right, but at least gcc and msvc agree on their results.
Please find attached a code snippet to reproduce the observed behavior.
I put this code snippet into Rextester:
http://rextester.com/l/cpp_online_compiler_gcc (g++ 5.4.0)
http://rextester.com/l/cpp_online_compiler_clang (clang 3.8.0)
http://rextester.com/l/cpp_online_compiler_visual (Microsoft 19.00.23506 for x86)
Output:
25214903928 206026503483683 245470556921330 (gcc)
25214903928 18444698300399350051 8295313034219953650 (clang)
25214903928 206026503483683 245470556921330 (msvc)
I also put this code snippet into a Compiler Explorer project. It illustrates
that Clang 3.8 and Clang trunk produce exactly the same code/values.
https://godbolt.org/g/rBSjaS
A possibly somehow related issue:
https://bugs.llvm.org/show_bug.cgi?id=27839
file_34206.txt
(215 bytes, text/plain)