https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jonathan Wakely <r...@gcc.gnu.org>: https://gcc.gnu.org/g:f9412cedd6c0e7417b30d9a80d3f45c8746223b4 commit r14-289-gf9412cedd6c0e7417b30d9a80d3f45c8746223b4 Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed Apr 26 15:23:57 2023 +0100 libstdc++: Make std::random_device throw std::system_error [PR105081] This changes std::random_device constructors to throw std::system_error (with EINVAL as the error code) when the constructor argument is invalid. We can also throw std::system_error when read(2) fails so that the exception includes the additional information provided by errno. As noted in the PR, this is consistent with libc++, and doesn't break any existing code which catches std::runtime_error, because those handlers will still catch std::system_error. libstdc++-v3/ChangeLog: PR libstdc++/105081 * src/c++11/random.cc (__throw_syserr): New function. (random_device::_M_init, random_device::_M_init_pretr1): Use new function for bad tokens. (random_device::_M_getval): Use new function for read errors. * testsuite/util/testsuite_random.h (random_device_available): Change catch handler to use std::system_error.