<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/114829>114829</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            libc++: Wrong Initial Distribution When Varying the Seed
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc++
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          jonas-eschmann
      </td>
    </tr>
</table>

<pre>
    The default random engine (`std::minstd_rand0`) produces a highly correlated initial distribution when varying the seeds (tested with clang 19.1.0 and seems to be the same for all prior versions):
```
#include <iostream>
#include <random>

int main(){
    for(int seed = 0; seed < 100; seed++){
        auto rng = std::default_random_engine(seed);
        float value = std::uniform_real_distribution<float>(0, 1)(rng);
        std::cout << value << "\n";
    }
    return 0;
}
```
**Output**
```
...
0.000101742
0.000109569
0.000117395
0.000125221
0.000133048
0.000140874
0.000148701
0.000156527
0.000164353
0.00017218
0.000180006
0.000187832
0.000195659
0.000203485
0.000211312
0.000219138
0.000226964
0.000234791
0.000242617
0.000250443
0.00025827
0.000266096
0.000273922
0.000281749
0.000289575
0.000297402
0.000305228
0.000313054
0.000320881
0.000328707
0.000336533
0.00034436
...
```

[https://godbolt.org/z/x7jrEcaME](https://godbolt.org/z/x7jrEcaME)

I think users would expect this to be uniformly distributed. GCC has the same issue but MSVC seems fine
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVc1y4ygQfhp8ocYFDRJw0CGxx1tzmNrDbM0cU0jCFlkMLkDJZJ9-C8tJUDaHdVGS-Oifr7txt07JnrwxHWruUbPf6DlPIXaPwev0xaRhOmvvN30YX7q_JoNHc9SzyzhqP4YzNv5kvcEIJGpJyiNid4jdna1PeXwoMgS1BIHClxjGeTAJazzZ0-Re8BBiNE5nM2Lrbbba4dGmHG0_Zxs8fp6Mx086vlh_wnkyOBkzpuIqm1S0nm2e8OC0P2Gqt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