Skip to content

Commit abefd5e

Browse files
Implement LWG-4014 LWG-3809 changes behavior of some existing std::subtract_with_carry_engine code (#5132)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent a8fea5b commit abefd5e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

stl/inc/random

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ public:
827827

828828
void seed(_Seed_t _Value = 0u, bool _Readcy = false) { // set initial values from specified seed value
829829
linear_congruential_engine<uint_least32_t, 40014U, 0U, 2147483563U> _Lc{
830-
static_cast<uint_least32_t>(_Value == 0U ? default_seed : _Value)};
830+
_Value == 0U ? default_seed : static_cast<uint_least32_t>(_Value % 2147483563U)};
831831
_Reset(_Lc, _Readcy);
832832
}
833833

tests/std/tests/Dev11_0577418_random_seed_0/test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ int main() {
2424
// Also test VSO-214595 "subtract_with_carry_engine::seed should accept result_type"
2525
subtract_with_carry_engine<unsigned long long, 64, 10, 24> ull_swc;
2626
ull_swc.seed(0x12341234'00000000ULL);
27-
assert(run_10k(ull_swc) == 0x1DD6C263'C41EEED0ULL); // value changed by LWG-3809
27+
assert(run_10k(ull_swc) == 0x01316AEA'3646F686ULL); // libstdc++ 14.2 and libc++ 19.1 agree, Boost 1.86.0 disagrees
2828

2929
assert(minstd_rand0(0) == minstd_rand0()); // N4964 [rand.eng.lcong]/5
3030
assert(mt19937(0) != mt19937()); // N4964 [rand.eng.mers]/6
3131
assert(ranlux24_base(0) == ranlux24_base()); // N4964 [rand.eng.sub]/7
3232

3333
assert(run_10k(minstd_rand0(0)) == 1043618065UL); // QED
34-
assert(run_10k(mt19937(0)) == 1543171712UL); // Boost 1.52.0 agrees
34+
assert(run_10k(mt19937(0)) == 1543171712UL); // Boost 1.86.0 agrees
3535
assert(run_10k(ranlux24_base(0)) == 7937952UL); // QED
3636

3737
// Also test LWG-3809 Is std::subtract_with_carry_engine<uint16_t> supposed to work?

0 commit comments

Comments
 (0)