[libcxx-commits] [PATCH] D65041: Change requirements on linear_congruential_engine

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 20 16:12:26 PDT 2019


zoecarver created this revision.
zoecarver added reviewers: mclow.lists, ldionne, EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, christof.

This patch changes how linear_congruential_engine picks its randomization algorithm. It adds two restrictions, `_OverflowOK` and `_SchrageOK`. `_OverflowOK` means that `m` is a power of two so using the classic `(a * x + c) % m` will create a meaningless overflow. The second checks that Schrage's algorithm will produce results that are in bounds of `min` and `max`. This patch fixes 27839 <https://bugs.llvm.org/show_bug.cgi?id=27839>.


Repository:
  rCXX libc++

https://reviews.llvm.org/D65041

Files:
  libcxx/include/random
  libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/alg.pass.cpp
  libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65041.210976.patch
Type: text/x-patch
Size: 5915 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190720/317d0d7b/attachment.bin>


More information about the libcxx-commits mailing list