[PATCH] D59254: [RFC] Implementation of Clang randstruct

Vlad Tsyrklevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 20:29:52 PDT 2019


vlad.tsyrklevich added inline comments.


================
Comment at: clang/include/clang/AST/RecordFieldReorganizer.h:54
+  std::seed_seq Seq;
+  std::default_random_engine rng;
+};
----------------
timpugh wrote:
> connorkuehl wrote:
> > pcc wrote:
> > > I don't think we can use `default_random_engine` for this because the behaviour would need to be consistent between C++ standard library implementations, and the behaviour of `default_random_engine` is implementation defined. Similarly, I don't think that we can use `std::shuffle` (see note in https://en.cppreference.com/w/cpp/algorithm/random_shuffle ).
> > Sure thing, we'll begin investigating alternatives.
> @pcc  if we were to swap `default_random_engine` for a pre-defined random generator such as `mt19937_64` would this suffice? It is included in the random number library.
> 
> https://en.cppreference.com/w/cpp/numeric/random
In that case the random numbers would be deterministic; however, std::shuffle would still vary by implementation (as mentioned in the note Peter linked to.) A quick search didn't reveal a deterministic shuffle in the LLVM code so you may have to implement one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59254/new/

https://reviews.llvm.org/D59254





More information about the cfe-commits mailing list