Opened 11 years ago

Closed 11 years ago

#6192 closed Patches (fixed)

Fix warnings passing non-POD to vararg function in math/special_functions/fpclassify.hpp

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

Description

Sun CC (and probably any other compiler for which BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS is defined) warns about passing non-POD struct to vararg is_generic_tag_false() overload. While this is probably harmless in practice because the function doesn't use its argument anyhow (and normally shouldn't be even called as it should be optimized away), it still results in nasty warnings (see below for the full text) so I suggest the following simple patch which just switches to using pointers instead of objects to fix this:

  • boost/math/special_functions/fpclassify.hpp

    old new  
    251251   typedef typename detail::fp_traits<T>::type traits;
    252252   typedef typename traits::method method;
    253253#ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
    254    if(std::numeric_limits<T>::is_specialized && detail::is_generic_tag_false(method()))
     254   if(std::numeric_limits<T>::is_specialized &&
     255       detail::is_generic_tag_false(static_cast<method*>(NULL)))
    255256      return detail::fpclassify_imp(t, detail::generic_tag<true>());
    256257   return detail::fpclassify_imp(t, method());
    257258#else
  • boost/math/special_functions/detail/fp_traits.hpp

    old new  
    101101// These helper functions are used only when numeric_limits<>
    102102// members are not compile time constants:
    103103//
    104 inline bool is_generic_tag_false(const generic_tag<false>&)
     104inline bool is_generic_tag_false(const generic_tag<false>*)
    105105{
    106106   return true;
    107107}
    108 inline bool is_generic_tag_false(...)
     108inline bool is_generic_tag_false(const void*)
    109109{
    110110   return false;
    111111}

While the patch is against the old 1.41 release and not the trunk, the relevant code doesn't seem to have changed since then.

P.S. For the reference, here are the warnings:

".../boost/math/special_functions/fpclassify.hpp", line 254: Warning, nonpodvarargw: A non-POD object of type "boost::math::detail::ieee_copy_leading_bits_tag" passed as a variable argument to function "boost::math::detail::is_generic_tag_false(...)".
".../boost/math/special_functions/gamma.hpp", line 591:     Where, temwhileinst: While instantiating "boost::math::fpclassify<long double>(long double)".
".../boost/math/special_functions/gamma.hpp", line 591:     Where, teminstfrom: Instantiated from boost::math::detail::full_igamma_prefix<long double, boost::math::policies::policy<boost::math::policies::promote_float<0>, boost::math::policies::promote_double<0>, 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>>(long double, long double, const boost::math::policies::policy<boost::math::policies::promote_float<0>, boost::math::policies::promote_double<0>, 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/gamma.hpp", line 977:     Where, teminstfrom: Instantiated from boost::math::detail::gamma_incomplete_imp<long double, boost::math::policies::policy<boost::math::policies::promote_float<0>, boost::math::policies::promote_double<0>, 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>>(long double, long double, bool, bool, const boost::math::policies::policy<boost::math::policies::promote_float<0>, boost::math::policies::promote_double<0>, 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>&, long double*).
".../boost/math/special_functions/gamma.hpp", line 1444:     Where, teminstend: Instantiated from non-template code.

Change History (1)

comment:1 by John Maddock, 11 years ago

Resolution: fixed
Status: newclosed

(In [76093]) Apply patch from #6192. Plus fix a few other issues that arise when BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS is set. Fixes #6192.

Note: See TracTickets for help on using tickets.