Modify

Ticket #6191 (closed Patches: fixed)

Opened 2 years ago

Last modified 2 years ago

Fix variable shadowing warning in igamma_inverse.hpp

Reported by: Vadim Zeitlin <vz-boost@…> Owned by: johnmaddock
Milestone: To Be Determined Component: math
Version: Boost 1.48.0 Severity: Cosmetic
Keywords: Cc:

Description

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:

  • igamma_inverse.hpp

    old new  
    279279         { 
    280280         // DiDonato and Morris Eq 35: 
    281281            T v = log(p) + boost::math::lgamma(ap1, pol); 
    282             T s = 1; 
    283282            z = exp((v + w) / a); 
    284283            s = boost::math::log1p(z / ap1 * (1 + z / (a + 2))); 
    285284            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.

Attachments

Change History

comment:1 Changed 2 years ago by Vadim Zeitlin <vz-boost@…>

  • Type changed from Bugs to Patches

comment:2 Changed 2 years ago by johnmaddock

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in Trunk revision #76094.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.