">>" operator of std::normal_distribution doesn't work properly

Solution Verified - Updated -

Issue

">>" operator of std::normal_distribution doesn't work properly.

The following reproducer, test.cpp, is expected to output "OK" according to the C++ standard, but it actually outputs "NG".

      test.cpp:
      #include <random>
      #include <sstream>
      #include <cstdio>

      int main()
      {
        std::normal_distribution<> d1(7, 5);
        std::stringstream ss;

        ss << d1;

        std::normal_distribution<> d2;
        ss >> d2;

        if (d1 == d2) puts("OK");
        else puts("NG");

        return 0;
      } 

Environment

  • Red Hat Enterprise Linux 8.4 or later
  • gcc

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content