Boost C++ Libraries: Ticket #4085: GCC warnings in normal_distribution.hpp https://svn.boost.org/trac10/ticket/4085 <p> GCC 4.4.3 with '-Wall -Wextra' compilation flags produce the following warning when compiling code using normal_distribution.hpp: </p> <p> warning: ‘delta.boost::variate_generator&lt;boost::lagged_fibonacci607&amp;, boost::normal_distribution&lt;double&gt; &gt;::_dist.boost::normal_distribution&lt;double&gt;::_r1’ may be used uninitialized in this function </p> <p> Indeed, both constructor of normal_distribution.hpp do not initialise the _r1, _r2 and _cached_rho members. It seems to me this has no consequences, because the logic of operator() initialises them as needed, but probably GCC is unable to detect this. </p> <p> The proposed patch (against 1.42.0) initialises to zero the _r1, _r2 and _cached_rho data members in both constructors. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4085 Trac 1.4.3 bluescarni@… Sun, 11 Apr 2010 22:31:00 GMT attachment set https://svn.boost.org/trac10/ticket/4085 https://svn.boost.org/trac10/ticket/4085 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">shut_off_gcc_warning_normal_distribution.diff</span> </li> </ul> <p> Proposed patch to initialise to zero the _r1, _r2 and _cached_rho data members of normal_distribution.hpp </p> Ticket Steven Watanabe Mon, 12 Apr 2010 15:17:41 GMT severity changed https://svn.boost.org/trac10/ticket/4085#comment:1 https://svn.boost.org/trac10/ticket/4085#comment:1 <ul> <li><strong>severity</strong> <span class="trac-field-old">Cosmetic</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> As a matter of fact, the stream operators can use _r1 and _cached_rho before they are initialized, so this is a real problem. </p> Ticket Steven Watanabe Tue, 08 Jun 2010 03:21:30 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4085#comment:2 https://svn.boost.org/trac10/ticket/4085#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/62545" title="Make sure that all members are initialized. Fixes #4085">[62545]</a>) Make sure that all members are initialized. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4085" title="#4085: Bugs: GCC warnings in normal_distribution.hpp (closed: fixed)">#4085</a> </p> Ticket