public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105081] New: Make std::random_device throw std::system_error
@ 2022-03-28 11:38 redi at gcc dot gnu.org
  2022-03-28 11:38 ` [Bug libstdc++/105081] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-28 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081

            Bug ID: 105081
           Summary: Make std::random_device throw std::system_error
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Unsupported constructor tokens could throw a std::system_error with
std::invalid_argument instead of just std::runtime_error. That would match what
libc++ does.

This shouldn't break any existing code, because a handler for
std::runtime_error will still catch a std::system_error exception.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/105081] Make std::random_device throw std::system_error
  2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
@ 2022-03-28 11:38 ` redi at gcc dot gnu.org
  2023-01-18 13:31 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-28 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/105081] Make std::random_device throw std::system_error
  2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
  2022-03-28 11:38 ` [Bug libstdc++/105081] " redi at gcc dot gnu.org
@ 2023-01-18 13:31 ` redi at gcc dot gnu.org
  2023-04-26  6:55 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2023-01-18 13:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-01-18
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We should add an overload of __throw_system_error that takes a const char*
because otherwise making this change would make the exception less informative.
Currently the std::runtime_error has a useful what() message:

      std::__throw_runtime_error(
          __N("random_device::random_device(const std::string&):"
              " unsupported token"));

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/105081] Make std::random_device throw std::system_error
  2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
  2022-03-28 11:38 ` [Bug libstdc++/105081] " redi at gcc dot gnu.org
  2023-01-18 13:31 ` redi at gcc dot gnu.org
@ 2023-04-26  6:55 ` rguenth at gcc dot gnu.org
  2023-04-27 10:29 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26  6:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|13.0                        |13.2

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.1 is being released, retargeting bugs to GCC 13.2.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/105081] Make std::random_device throw std::system_error
  2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-04-26  6:55 ` rguenth at gcc dot gnu.org
@ 2023-04-27 10:29 ` cvs-commit at gcc dot gnu.org
  2023-04-27 10:36 ` redi at gcc dot gnu.org
  2023-06-30 14:09 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-27 10:29 UTC (permalink / raw)
  To: gcc-bugs

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 <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:f9412cedd6c0e7417b30d9a80d3f45c8746223b4

commit r14-289-gf9412cedd6c0e7417b30d9a80d3f45c8746223b4
Author: Jonathan Wakely <jwakely@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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/105081] Make std::random_device throw std::system_error
  2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-04-27 10:29 ` cvs-commit at gcc dot gnu.org
@ 2023-04-27 10:36 ` redi at gcc dot gnu.org
  2023-06-30 14:09 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2023-04-27 10:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|13.2                        |14.0

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Done for GCC 14

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libstdc++/105081] Make std::random_device throw std::system_error
  2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-04-27 10:36 ` redi at gcc dot gnu.org
@ 2023-06-30 14:09 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-30 14:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105081

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:d6a6a4ea086d6af97bd7fbd482f51df41c265b79

commit r14-2217-gd6a6a4ea086d6af97bd7fbd482f51df41c265b79
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jun 30 14:37:59 2023 +0100

    libstdc++: Make std::random_device throw more std::system_error [PR105081]

    In r14-289-gf9412cedd6c0e7 I made the std::random_device constructor
    throw std::system_error for unrecognized tokens. But it still throws
    std::runtime_error for a token such as "rdseed" that is recognized but
    not supported at runtime by the CPU the program is running on.

    With this change we throw std::system_error for those cases too. This
    fixes the following failures on Intel CPUs withour rdseed support:

    FAIL: 26_numerics/random/random_device/94087.cc execution test
    FAIL: 26_numerics/random/random_device/cons/token.cc execution test
    FAIL: 26_numerics/random/random_device/entropy.cc execution test

    libstdc++-v3/ChangeLog:

            PR libstdc++/105081
            * src/c++11/random.cc (random_device::_M_init): Throw
            std::system_error when the requested device is a valid token but
            not available at runtime.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-06-30 14:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 11:38 [Bug libstdc++/105081] New: Make std::random_device throw std::system_error redi at gcc dot gnu.org
2022-03-28 11:38 ` [Bug libstdc++/105081] " redi at gcc dot gnu.org
2023-01-18 13:31 ` redi at gcc dot gnu.org
2023-04-26  6:55 ` rguenth at gcc dot gnu.org
2023-04-27 10:29 ` cvs-commit at gcc dot gnu.org
2023-04-27 10:36 ` redi at gcc dot gnu.org
2023-06-30 14:09 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).