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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-05-14

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
So it looks like the rdseed usage is new in GCC 10 libstdc++ and it prevails
over the previous rdrand support if supported on your CPU.

I can reproduce this on a CPU with rdseed support and libstdc++ from GCC 10.

The code invoked looks correct to me:

  20:   83 e8 01                sub    $0x1,%eax
  23:   74 12                   je     37
<_ZNSt12_GLOBAL__N_112__x86_rdseedEPv+
0x37>
  25:   f3 90                   pause  
  27:   0f c7 fa                rdseed %edx
  2a:   89 11                   mov    %edx,(%rcx)
  2c:   73 f2                   jae    20
<_ZNSt12_GLOBAL__N_112__x86_rdseedEPv+
0x20>

the number of tries libstdc++ does is 100.  Note rdrand doesn't exhibit this
issue.

So it might very well be a hardware limitation.  Btw, the reproducer can be
"enhanced" by providing the method of operation:

        std::random_device rd("rdseed");

that makes sure it will fail in a different way on a not capable CPU
(Intel Broadwell or later or AMD Zen).

Reply via email to