diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-04-30 01:36:09 +0200 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-04-29 23:36:09 +0000 |
commit | cf48c255197fb4aae6bc1acc2eba31f13a3f44b3 (patch) | |
tree | 9adf35dcdbd754a14ae986576a07b43387e41d70 /libstdc++-v3/testsuite/26_numerics | |
parent | 143a1ce16cee1ade7a09266a3a0190ee2e826734 (diff) | |
download | gcc-cf48c255197fb4aae6bc1acc2eba31f13a3f44b3.zip gcc-cf48c255197fb4aae6bc1acc2eba31f13a3f44b3.tar.gz gcc-cf48c255197fb4aae6bc1acc2eba31f13a3f44b3.tar.bz2 |
re PR libstdc++/51795 (linear_congruential_engine doesn't work correctly)
2012-04-29 Marc Glisse <marc.glisse@inria.fr>
Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/51795
* include/bits/stl_algobase.h (__lg<>(_Size)): Remove.
(__lg(int), __lg(unsigned), __lg(long), __lg(unsigned long),
__lg(long long), __lg(unsigned long long)): Define constexpr.
* include/bits/random.h (_Mod<>): Overcome Schrage's algorithm
limitations.
(__mod): Adjust.
(linear_congruential): Remove FIXME static_assert.
* include/bits/random.tcc (_Mod<>): Adjust.
* testsuite/26_numerics/random/linear_congruential_engine/operators/
51795.cc: New.
Co-Authored-By: Paolo Carlini <paolo.carlini@oracle.com>
From-SVN: r186948
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics')
-rw-r--r-- | libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/51795.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/51795.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/51795.cc new file mode 100644 index 0000000..a626df0 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/operators/51795.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++11" } +// { dg-require-cstdint "" } +// +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 26.5.3.1 class template linear_congruential_engine [rand.eng.lcong] + +#include <random> +#include <testsuite_hooks.h> + +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::linear_congruential_engine<std::uint64_t, 1103515245ULL, + 12345, 2147483648ULL> engine; + engine eng(1103527590ULL); + + for (unsigned it = 0; it < 1000; ++it) + { + std::uint64_t num = eng(); + VERIFY( (num >= eng.min() && num <= eng.max()) ); + } +} + +int main() +{ + test01(); + return 0; +} |