Skip to content

Conversation

MattStephanson
Copy link
Contributor

It's perfectly stable, so long as tha don't shift it about too much....

—Thomas Pynchon, Mason & Dixon

Fixes #5719.

The second loop in operator() is fine because it's only executed if multiple random values are needed (modulo the rejection sampling), i.e., _Nx > 1. In such cases, _Wx0 <= _Wx / _Nx <= sizeof(_Eres)*8 / 2, so _Wx0+1 < sizeof(_Eres)*8 as long as _Eres is more than two bits.

@StephanTLavavej StephanTLavavej added the bug Something isn't working label Sep 25, 2025
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Sep 25, 2025
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Sep 25, 2025
@StephanTLavavej StephanTLavavej merged commit 48db51b into microsoft:main Sep 25, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Merging to Done in STL Code Reviews Sep 25, 2025
@StephanTLavavej
Copy link
Member

Thanks for fixing the STL's most common UB mistake! ⏪ 😻 ⏩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

<random>: independent_bits_engine performs forbidden full shifts
2 participants