gcc/libstdc++-v3/testsuite/26_numerics
Jonathan Wakely c224dec0e7 libstdc++: Fix non-portable results from 64-bit std::subtract_with_carry_engine [PR107466]
I implemented the resolution of LWG 3809 in r13-4364-ga64775a0edd469 but
it was recently noted in the MSVC STL github repo that the change causes
possible truncation for 64-bit seeds. Whether the truncation occurs (and
to what value) depends on the width of uint_least32_t which is not
portable, so the output of the PRNG for 64-bit seed values is no longer
the same as in C++20, and no longer portable across platforms.

That new issue was filed as LWG 4014. I proposed a new change which
reduces the seed by the LCG's modulus before the conversion to
uint_least32_t. This ensures that 64-bit seed values are consistently
reduced by the modulus before any truncation. This removes the
platform-dependent behaviour and restores the old behaviour for
std::subtract_with_carry_engine specializations using a 64-bit result
type (such as std::ranlux48_base).

libstdc++-v3/ChangeLog:

	PR libstdc++/107466
	* include/bits/random.tcc (subtract_with_carry_engine::seed):
	Implement proposed resolution of LWG 4014.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
	* testsuite/26_numerics/random/subtract_with_carry_engine/cons/lwg3809.cc:
	Check for expected result of 64-bit engine with seed that
	doesn't fit in 32-bits.
2024-01-13 00:11:44 +00:00
..
accumulate Update copyright years. 2024-01-03 12:19:35 +01:00
adjacent_difference Update copyright years. 2024-01-03 12:19:35 +01:00
bit Update copyright years. 2024-01-03 12:19:35 +01:00
complex Update copyright years. 2024-01-03 12:19:35 +01:00
endian Update copyright years. 2024-01-03 12:19:35 +01:00
exclusive_scan Update copyright years. 2024-01-03 12:19:35 +01:00
gcd Update copyright years. 2024-01-03 12:19:35 +01:00
headers Update copyright years. 2024-01-03 12:19:35 +01:00
inclusive_scan Update copyright years. 2024-01-03 12:19:35 +01:00
inner_product Update copyright years. 2024-01-03 12:19:35 +01:00
iota Update copyright years. 2024-01-03 12:19:35 +01:00
lcm Update copyright years. 2024-01-03 12:19:35 +01:00
lerp Update copyright years. 2024-01-03 12:19:35 +01:00
midpoint Update copyright years. 2024-01-03 12:19:35 +01:00
numbers Update copyright years. 2024-01-03 12:19:35 +01:00
partial_sum Update copyright years. 2024-01-03 12:19:35 +01:00
pstl/numeric_ops
random libstdc++: Fix non-portable results from 64-bit std::subtract_with_carry_engine [PR107466] 2024-01-13 00:11:44 +00:00
reduce Update copyright years. 2024-01-03 12:19:35 +01:00
saturation libstdc++: Define C++26 saturation arithmetic functions (P0543R3) 2023-11-17 15:28:30 +00:00
slice Update copyright years. 2024-01-03 12:19:35 +01:00
slice_array Update copyright years. 2024-01-03 12:19:35 +01:00
transform_exclusive_scan Update copyright years. 2024-01-03 12:19:35 +01:00
transform_inclusive_scan Update copyright years. 2024-01-03 12:19:35 +01:00
transform_reduce Update copyright years. 2024-01-03 12:19:35 +01:00
valarray Update copyright years. 2024-01-03 12:19:35 +01:00