https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100444
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- So at least libstdc++ does check RDRAND availability via cpuid. It also already checks the return value for "no avaialble randomness": while (__builtin_ia32_rdrand32_step(&val) == 0) if (--retries == 0) std::__throw_runtime_error(__N("random_device: rdrand failed")); so here it could check for -1 as well though in theory that can happen with true randomness as well, even if very unlikely. Note that it would never return -1 then (as it never returns 0 at the moment). Thus I believe the issue is mitigated at the kernel level and people that cannot be bothered to update their ucode or the kernel are not likely bothered to update libstdc++ either. Note handling it above would raise a runtime error rather than falling back to other sources of randomness. Doing the checking where we detect rdrand support would avoid that.