diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index 7f4bf5ea1836e6540aa92f38ca6562bef41f6e1d..ade416390b378c5c07865ccce8edbf1757ea5f78 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -541,8 +541,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION subtract_with_carry_engine<_UIntType, __w, __s, __r>:: seed(result_type __value) { + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 3809. Is std::subtract_with_carry_engine<uint16_t> supposed to work? + // 4014. LWG 3809 changes behavior of some existing code std::linear_congruential_engine<uint_least32_t, 40014u, 0u, 2147483563u> - __lcg(__value == 0u ? default_seed : __value); + __lcg(__value == 0u ? default_seed : __value % 2147483563u); const size_t __n = (__w + 31) / 32; diff --git a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc index c58f480640f63597921db92cc6617bd3349ff831..59cf84adb48d32e5f08ac920a792e9efb9edd3cb 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc @@ -12,4 +12,4 @@ auto x = std::generate_canonical<std::size_t, // { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 169 } -// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3348 } +// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3351 } diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc index d91ee7448f6044ebf558dd877a6d67ffbe266fd5..b6fb57f8eeb287d83c68eed6c16cff458d182c11 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc @@ -2,10 +2,11 @@ #include <random> #include <testsuite_hooks.h> -// LWG 3809. Is std::subtract_with_carry_engine<uint16_t> supposed to work? // PR 107466 - invalid -Wnarrowing error with std::subtract_with_carry_engine -int main() +// LWG 3809. Is std::subtract_with_carry_engine<uint16_t> supposed to work? +void +test_lwg3809() { // It should be possible to construct this engine with a 16-bit result_type: std::subtract_with_carry_engine<uint16_t, 12, 5, 12> s16; @@ -24,3 +25,17 @@ int main() for (int i = 0; i < 10; ++i) VERIFY( s16() == s32() ); } + +// LWG 4014. LWG 3809 changes behavior of some existing code +void +test_lwg4014() +{ + std::ranlux48_base g(-1U + 1LL); + VERIFY( g() == 22575453646312 ); +} + +int main() +{ + test_lwg3809(); + test_lwg4014(); +}