Subject: [Boost-bugs] [Boost C++ Libraries] #10985: Logically dead code; dubious source code comment / inverted if condition?
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-30 21:10:57
#10985: Logically dead code; dubious source code comment / inverted if condition?
--------------------------------------+-------------------------
Reporter: Jonas Maaskola <jonas@â¦> | Owner: johnmaddock
Type: Bugs | Status: new
Milestone: To Be Determined | Component: math
Version: Boost 1.57.0 | Severity: Problem
Keywords: |
--------------------------------------+-------------------------
Static code analysis with Coverity pointed me to some dead code in the
function ibeta_imp in boost/math/special_functions/beta.hpp.
My system's boost library is 1.55.0, but the issue is present identically
in boost 1.57.
In a block guarded by
{{{
if (normalised) {
}}}
there is the following line (number 1224):
{{{
fract -= (normalised ? 1 : boost::math::beta(a, b, pol));
}}}
Clearly, normalised has to be true due to the if guard thus the second
part (boost::math::beta(a, b, pos)) will never be used.
Furthermore, it may be that the if guard's condition is missing a negation
for which there are two indications:
* in the vicinity (i.e. in the function ibeta_imp) most other if
statements (6 of 7) that involve normalised check if normalised is not set
(i.e. "if(!normalised)"), and
* more importantly, the first comment in that block on lines 1211-1213
reads:
{{{
1209: else if(normalised)
1210: {
1211: // the formula here for the non-normalised case is tricky
to figure
1212: // out (for me!!), and requires two pochhammer
calculations rather
1213: // than one, so leave it for now....
}}}
I apologize for my limited understanding of the details of the code, which
precludes me from proposing a fix, but something seems fishy here!
Finally, the line subsequent to the one with the dead code, i.e. line
1225, contains a commented-out alternative. This indicates to me that this
entire block may not have been fully satisfactory to the original
author(s).
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10985> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC