-
-
Notifications
You must be signed in to change notification settings - Fork 453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rand::rngs::StdRng produces different values in/out struct #1463
Comments
This can be run from the playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8d72ab06f71630e19818510ea55b2261 I noticed that commenting out one line in particular affects the result. |
Testing with v0.9.0-alpha.1 yields the same sequence for direct usage of |
Without diving into the code, it is feasible that there is a bug in We have plans to replace this entire implementation (#934), so this bug might get fixed as a side-effect. |
I don't think it's an issue with ChaCha. I just reproduced this issue with the Isaac rngs, Hc128, and various Xorshift/Xoshiro/Xoroshiro rngs |
Ah it's because the compiler is changing the type of |
Fine. Adding the |
For clarity: In the struct, you are specifying the type as |
Code sample
I provide a minimal repo with 40 lines of code for this issue: https://github.com/TOPbuaa/mini_test_rand.
Summary
When I use rand inside a struct with the same seed, the results are different from when it is outside the struct.
Is my usage wrong? or is there a bug causing undefined behavior?
The text was updated successfully, but these errors were encountered: