http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59800
Bug ID: 59800 Summary: Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rionda at gmail dot com Created attachment 31828 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31828&action=edit Code that fails The attached code compiles cleanly when using g++ -Ofast -Wall -Wextra -Wno-unused-parameter test.cpp test.cpp and when using g++ -flto -Wall -Wextra -Wno-unused-parameter test.cpp but fails when using "g++8 -std=c++11 -Ofast -flto -Wall -Wextra -Wno-unused-parameter test.cpp" (i.e., when using both -Ofast and -flto). The reported error is: test.cpp: In function 'main': /opt/local/include/gcc48/c++/bits/random.h:2404:60: warning: 'MEM[(struct normal_distribution *)&my_lognormal + 16B]._M_saved' may be used uninitialized in this function [-Wmaybe-uninitialized] { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); } ^ test.cpp:11:33: note: 'MEM[(struct normal_distribution *)&my_lognormal + 16B]._M_saved' was declared here lognormal_distribution<double> my_lognormal(0.0, 1.0); ^ I am running g++-mp-4.8 (MacPorts gcc48 4.8.2_0) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. on Mac OS X 10.6.8 (uname -a : darwin xxxx.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386)