Files
gcc/libstdc++-v3/include
Elena Tyuleneva 1bb8dc29aa libstdc++: Fix philox_engine counter increment carry
The philox counter increment that happens in
philox_engine::_M_transition(), applies +1 to _M_x[0] before the bitwise
OR with (_M_x[1] << __w), so the carry from _M_x[0] is merged into the
_M_x[1] portion rather than being added to it. This causes the counter
to cycle prematurely and never advance past {0, 0, 1, 2^w - 1}.

Fix by changing operations order, which results in forming the
full-width value from _M_x[1]:_M_x[0] and then adding 1 on both the n ==
4 and n == 2 paths.

libstdc++-v3/ChangeLog:

	* include/bits/random.tcc (philox_engine::_M_transtiion): Fix
	counter increment to propagate carry correctly.
	* testsuite/26_numerics/random/philox_engine/operators/counter_carry.cc:
	New test.

Signed-off-by: Elena Tyuleneva <elena.tyuleneva@intel.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2026-04-15 17:51:49 +01:00
..
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00
2026-01-02 09:56:11 +01:00