[libcxx-commits] [PATCH] D114129: [libc++] Fix `uniform_int_distribution` for 128-bit result type

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 18 15:07:50 PST 2021


Quuxplusone added a subscriber: mclow.lists.
Quuxplusone added a comment.

> binomial_distribution also seems to be affected, and maybe others as well. But I haven't looked into them deeply yet, and it's not obvious from looking at the code briefly what causes the problem there.
>
> Also, is there a reason why uniform_int_distribution.h defines its own independent_bits_engine instead of using the one from the random header?

On both of those questions (but especially the second), I tentatively propose that we (I?) should granularize `<random>` into `<__random/*.h>` //before// landing this PR. (Which will merge-conflict horribly, no matter which way we do things. Unless people think we should just land this one ASAP. I wouldn't //object// to that, but I wouldn't necessarily encourage it either.)

> And, out of curiosity, because I haven't been able to figure it out by myself and must be overlooking something: Do you happen to know why the simple definition of independent_bits_engine (here, 26.4.4.2) was dropped in favor of the much more complicated one that made it into the standard?

Way before my time; I wonder if @mclow.lists would remember. :) What little I've got: That engine was absent from N1932 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1932.pdf>, which was discussed in Berlin 2006 (the meeting notes are not enlightening to me); N2079 <http://open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2079.pdf> had the "simple" version of `random_bits_engine`, with some comments indicating that getting the math exactly technically right on `generate_canonical` was harder than it looked; I don't know where N2079 was discussed (presumably Portland though); and then its successor N2111 <http://open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2111.pdf> had the "complicated" version of `independent_bits_engine` and was voted into the Standard in Portland 2006 (the meeting notes are just a straw poll on voting in the still-draft-numbered d2111, no recorded discussion).


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

https://reviews.llvm.org/D114129



More information about the libcxx-commits mailing list