public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100444] New: std::random_device isn't random on AMD
@ 2021-05-06  7:45 ecree429 at virginmedia dot com
  2021-05-06  7:52 ` [Bug libstdc++/100444] " rguenth at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: ecree429 at virginmedia dot com @ 2021-05-06  7:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100444
           Summary: std::random_device isn't random on AMD
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ecree429 at virginmedia dot com
  Target Milestone: ---

On certain AMD processors (in my case Ryzen 5 3600, stepping 0, microcode
0x8701013), RDRAND instruction is broken and always returns all-1s.  Thus e.g.
    #include <iostream>
    #include <random>

    int main(void)
    {
      static std::random_device rd;
      std::cout << rd() << '\n';
    }
always prints 4294967295.

Other RNG implementations such as Qt's QRandomGenerator detect this brokenness
and work around it, falling back to an alternate source of entropy.  libstdc++
should ideally do the same, rather than silently failing to be random.

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

end of thread, other threads:[~2021-10-04 12:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  7:45 [Bug libstdc++/100444] New: std::random_device isn't random on AMD ecree429 at virginmedia dot com
2021-05-06  7:52 ` [Bug libstdc++/100444] " rguenth at gcc dot gnu.org
2021-05-06  8:48 ` ecree429 at virginmedia dot com
2021-05-06  8:49 ` pinskia at gcc dot gnu.org
2021-05-06  8:58 ` rguenth at gcc dot gnu.org
2021-05-06 10:05 ` redi at gcc dot gnu.org
2021-05-06 10:22 ` redi at gcc dot gnu.org
2021-05-06 10:51 ` ecree429 at virginmedia dot com
2021-05-06 11:25 ` redi at gcc dot gnu.org
2021-05-06 11:39 ` rguenth at gcc dot gnu.org
2021-05-06 11:41 ` redi at gcc dot gnu.org
2021-05-10 20:20 ` redi at gcc dot gnu.org
2021-05-13 18:46 ` ecree429 at virginmedia dot com
2021-05-14  9:23 ` redi at gcc dot gnu.org
2021-09-25 20:07 ` redi at gcc dot gnu.org
2021-10-04 12:20 ` redi 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).