Although the example in std::normal_distribution reference compiled fine, I got a warning on uninitialized value in a similar code below.
#include <random>
void foo(double);
int main()
{
std::default_random_engine generator;
std::normal_distribution<double> norm_dist(0,1);
for(int i=0; i<3; i++)
foo(norm_dist(generator));
return 0;
}
When compiled with "g++ -std=c++11 -Wall -ffast-math -O -c foo.cpp" using gcc5.3.1 on my CentOS7.2, I got:
foo.cpp:8:30: warning: ‘norm_dist.std::normal_distribution::_M_saved’ may be used uninitialized in this function [-Wmaybe-uninitialized] foo(norm_dist(generator));
I thought STL had been well tested, but why does the compiler warn? Is the problem in g++, STL, or my code?