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: | 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 251 251 typedef typename detail::fp_traits<T>::type traits; 252 252 typedef typename traits::method method; 253 253 #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))) 255 256 return detail::fpclassify_imp(t, detail::generic_tag<true>()); 256 257 return detail::fpclassify_imp(t, method()); 257 258 #else -
boost/math/special_functions/detail/fp_traits.hpp
old new 101 101 // These helper functions are used only when numeric_limits<> 102 102 // members are not compile time constants: 103 103 // 104 inline bool is_generic_tag_false(const generic_tag<false> &)104 inline bool is_generic_tag_false(const generic_tag<false>*) 105 105 { 106 106 return true; 107 107 } 108 inline bool is_generic_tag_false( ...)108 inline bool is_generic_tag_false(const void*) 109 109 { 110 110 return false; 111 111 }
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.
(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.