Boost C++ Libraries: Ticket #6191: Fix variable shadowing warning in igamma_inverse.hpp https://svn.boost.org/trac10/ticket/6191 <p> A local variable <code>s</code> is redefined in <code>find_inverse_gamma()</code> helper defined in the file <code>math/special_functions/detail/igamma_inverse.hpp</code> 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 <code>-Wshadow</code>) would give this warning as well so I'd like to ask for the following trivial patch to be applied to fix it: </p> <div class="wiki-code"> <div class="diff"> <ul class="entries"> <li class="entry"> <h2> <a>igamma_inverse.hpp</a> </h2> <table class="trac-diff inline" cellspacing="0"> <colgroup> <col class="lineno"/><col class="lineno"/><col class="content"/> </colgroup> <thead> <tr> <th title="File igamma_inverse.hpp.orig Thu Dec 1 18:00:20 2011"> old </th> <th title="File igamma_inverse.hpp Thu Dec 1 18:01:27 2011"> new </th> <td> <em></em> &nbsp; </td> </tr> </thead> <tbody class="unmod"> <tr> <th>279</th><th>279</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{</span></td> </tr> <tr> <th>280</th><th>280</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// DiDonato and Morris Eq 35:</span></td> </tr> <tr> <th>281</th><th>281</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; T v = log(p) + boost::math::lgamma(ap1, pol);</span></td> </tr> </tbody> <tbody class="rem"> <tr class="last first"> <th>282</th><th>&nbsp;</th><td class="l"><del>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; T s = 1;</del></td> </tr> </tbody> <tbody class="unmod"> <tr> <th>283</th><th>282</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = exp((v + w) / a);</span></td> </tr> <tr> <th>284</th><th>283</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s = boost::math::log1p(z / ap1 * (1 + z / (a + 2)));</span></td> </tr> <tr> <th>285</th><th>284</th><td class="l"><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; z = exp((v + z - s) / a);</span></td> </tr> </tbody> </table> </li> </ul> </div></div><p> 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 <code>s</code> in nested scope to something else (its initialization is still unneeded though). </p> <p> TIA! </p> <p> P.S. The warning: </p> <pre class="wiki">".../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&lt;double, boost::math::policies::policy&lt;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&gt;&gt;(double, double, double, const boost::math::policies::policy&lt;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&gt;&amp;, bool*)". ".../boost/math/special_functions/detail/igamma_inverse.hpp", line 406: Where, teminstfrom: Instantiated from boost::math::detail::gamma_p_inv_imp&lt;double, boost::math::policies::policy&lt;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&gt;&gt;(double, double, const boost::math::policies::policy&lt;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&gt;&amp;). ".../boost/math/special_functions/detail/igamma_inverse.hpp", line 517: Where, teminstend: Instantiated from non-template code. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6191 Trac 1.4.3 Vadim Zeitlin <vz-boost@…> Thu, 01 Dec 2011 18:18:13 GMT type changed https://svn.boost.org/trac10/ticket/6191#comment:1 https://svn.boost.org/trac10/ticket/6191#comment:1 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> </ul> Ticket John Maddock Wed, 21 Dec 2011 18:01:09 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6191#comment:2 https://svn.boost.org/trac10/ticket/6191#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> Fixed in Trunk revision <a class="missing ticket">#76094</a>. </p> Ticket