Opened 13 years ago
Closed 12 years ago
#4085 closed Bugs (fixed)
GCC warnings in normal_distribution.hpp
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | Boost 1.43.0 | Component: | random |
Version: | Boost 1.42.0 | Severity: | Problem |
Keywords: | Cc: |
Description
GCC 4.4.3 with '-Wall -Wextra' compilation flags produce the following warning when compiling code using normal_distribution.hpp:
warning: ‘delta.boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<double> >::_dist.boost::normal_distribution<double>::_r1’ may be used uninitialized in this function
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.
The proposed patch (against 1.42.0) initialises to zero the _r1, _r2 and _cached_rho data members in both constructors.
Attachments (1)
Change History (3)
by , 13 years ago
Attachment: | shut_off_gcc_warning_normal_distribution.diff added |
---|
comment:1 by , 13 years ago
Severity: | Cosmetic → Problem |
---|
As a matter of fact, the stream operators can use _r1 and _cached_rho before they are initialized, so this is a real problem.
comment:2 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Proposed patch to initialise to zero the _r1, _r2 and _cached_rho data members of normal_distribution.hpp