Subject: [Boost-bugs] [Boost C++ Libraries] #6191: Fix variable shadowing warning in igamma_inverse.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-12-01 17:12:48
#6191: Fix variable shadowing warning in igamma_inverse.hpp
---------------------------------------------------+------------------------
Reporter: Vadim Zeitlin <vz-boost@â¦> | Owner: johnmaddock
Type: Bugs | Status: new
Milestone: To Be Determined | Component: math
Version: Boost 1.48.0 | Severity: Cosmetic
Keywords: |
---------------------------------------------------+------------------------
A local variable `s` is redefined in `find_inverse_gamma()` helper defined
in the file `math/special_functions/detail/igamma_inverse.hpp` resulting
in annoyingly long warnings from Sun CC compiler (see below for the
warning in its full glory). I suspect other compilers (e.g. g++ with
`-Wshadow`) would give this warning as well so I'd like to ask for the
following trivial patch to be applied to fix it:
{{{
#!diff
--- igamma_inverse.hpp.orig Thu Dec 1 18:00:20 2011
+++ igamma_inverse.hpp Thu Dec 1 18:01:27 2011
@@ -279,7 +279,6 @@
{
// DiDonato and Morris Eq 35:
T v = log(p) + boost::math::lgamma(ap1, pol);
- T s = 1;
z = exp((v + w) / a);
s = boost::math::log1p(z / ap1 * (1 + z / (a + 2)));
z = exp((v + z - s) / a);
}}}
Removing the declaration and initialization shouldn't change the meaning
of the existing code because the variable is not used before it's assigned
below and the variable with the same name in enclosing scope is not used
any more. But if you prefer you could also just rename this `s` in nested
scope to something else (its initialization is still unneeded though).
TIA!
P.S. The warning:
{{{
".../boost/math/special_functions/detail/igamma_inverse.hpp", line 282:
Warning, wvarhidenmem: s hides the same name in an outer scope.
".../boost/math/special_functions/detail/igamma_inverse.hpp", line 406:
Where, temwhileinst: While instantiating
"boost::math::detail::find_inverse_gamma<double,
boost::math::policies::policy<boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy>>(double, double, double, const
boost::math::policies::policy<boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy>&, bool*)".
".../boost/math/special_functions/detail/igamma_inverse.hpp", line 406:
Where, teminstfrom: Instantiated from
boost::math::detail::gamma_p_inv_imp<double,
boost::math::policies::policy<boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy>>(double, double, const
boost::math::policies::policy<boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy,
boost::math::policies::default_policy>&).
".../boost/math/special_functions/detail/igamma_inverse.hpp", line 517:
Where, teminstend: Instantiated from non-template code.
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6191> 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:07 UTC