<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Linear congruential generator produces other values than gcc and msvc"
href="https://bugs.llvm.org/show_bug.cgi?id=34206">34206</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Linear congruential generator produces other values than gcc and msvc
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dirk.reinbach@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18991" name="attach_18991" title="linear_congruential_engine test">attachment 18991</a> <a href="attachment.cgi?id=18991&action=edit" title="linear_congruential_engine test">[details]</a></span>
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:
<a href="http://rextester.com/l/cpp_online_compiler_gcc">http://rextester.com/l/cpp_online_compiler_gcc</a> (g++ 5.4.0)
<a href="http://rextester.com/l/cpp_online_compiler_clang">http://rextester.com/l/cpp_online_compiler_clang</a> (clang 3.8.0)
<a href="http://rextester.com/l/cpp_online_compiler_visual">http://rextester.com/l/cpp_online_compiler_visual</a> (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.
<a href="https://godbolt.org/g/rBSjaS">https://godbolt.org/g/rBSjaS</a>
A possibly somehow related issue:
<a class="bz_bug_link
bz_status_NEW "
title="NEW - Linear congruential generator generates invalid values"
href="show_bug.cgi?id=27839">https://bugs.llvm.org/show_bug.cgi?id=27839</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>