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

548. May random_device block?

Section: 28.5.7 [rand.device], 99 [tr.rand.device] Status: NAD Submitter: Matt Austern Opened: 2006-01-10 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [rand.device].

View all issues with NAD status.

Discussion:

Class random_device "produces non-deterministic random numbers", using some external source of entropy. In most real-world systems, the amount of available entropy is limited. Suppose that entropy has been exhausted. What is an implementation permitted to do? In particular, is it permitted to block indefinitely until more random bits are available, or is the implementation required to detect failure immediately? This is not an academic question. On Linux a straightforward implementation would read from /dev/random, and "When the entropy pool is empty, reads to /dev/random will block until additional environmental noise is gathered." Programmers need to know whether random_device is permitted to (or possibly even required to?) behave the same way.

[ Berlin: Walter: N1932 considers this NAD. Does the standard specify whether std::cin may block? ]

See N2391 and N2423 for some further discussion.

Proposed resolution:

Adopt the proposed resolution in N2423 (NAD).