This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

3809. Is std::subtract_with_carry_engine<uint16_t> supposed to work?

Section: 28.5.4.4 [rand.eng.sub] Status: New Submitter: Jonathan Wakely Opened: 2022-11-02 Last modified: 2022-11-12

Priority: 3

View all other issues in [rand.eng.sub].

View all issues with New status.

Discussion:

The standard requires subtract_with_carry_engine<T> to use:

linear_congruential_engine<T, 40014u, 0u, 2147483563u>

where each of those values is converted to T.

This appears to mean subtract_with_carry_engine cannot be used with uint16_t, because 2147483563u cannot be converted to uint16_t without narrowing.

What is the intention here? Should it be ill-formed? Should the seed engine be linear_congruential_engine<uint_least32_t, …> instead? The values from the linear_congruential_engine are used modulo 2^32 so getting 64-bit values from it is pointless, and getting 16-bit values from it doesn't compile.

[Kona 2022-11-12; Set priority to 3]

Proposed resolution: