[Boost-bugs] [Boost C++ Libraries] #6192: Fix warnings passing non-POD to vararg function in math/special_functions/fpclassify.hpp

Subject: [Boost-bugs] [Boost C++ Libraries] #6192: Fix warnings passing non-POD to vararg function in math/special_functions/fpclassify.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-12-01 18:15:17


#6192: Fix warnings passing non-POD to vararg function in
math/special_functions/fpclassify.hpp
---------------------------------------------------+------------------------
 Reporter: Vadim Zeitlin <vz-boost@…> | Owner: johnmaddock
     Type: Patches | Status: new
Milestone: To Be Determined | Component: math
  Version: Boost 1.48.0 | Severity: Cosmetic
 Keywords: |
---------------------------------------------------+------------------------
 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:
 {{{
 #!diff
 --- boost_1_41_0.orig/boost/math/special_functions/fpclassify.hpp
 Thu Dec 1 19:03:56 2011
 +++ boost_1_41_0/boost/math/special_functions/fpclassify.hpp Thu Dec 1
 19:04:48 2011
 @@ -251,7 +251,8 @@
     typedef typename detail::fp_traits<T>::type traits;
     typedef typename traits::method method;
  #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
 - if(std::numeric_limits<T>::is_specialized &&
 detail::is_generic_tag_false(method()))
 + if(std::numeric_limits<T>::is_specialized &&
 + detail::is_generic_tag_false(static_cast<method*>(NULL)))
        return detail::fpclassify_imp(t, detail::generic_tag<true>());
     return detail::fpclassify_imp(t, method());
  #else
 --- boost_1_41_0.orig/boost/math/special_functions/detail/fp_traits.hpp
 Thu Dec 1 19:04:06 2011
 +++ boost_1_41_0/boost/math/special_functions/detail/fp_traits.hpp
 Thu Dec 1 19:06:45 2011
 @@ -101,11 +101,11 @@
  // These helper functions are used only when numeric_limits<>
  // members are not compile time constants:
  //
 -inline bool is_generic_tag_false(const generic_tag<false>&)
 +inline bool is_generic_tag_false(const generic_tag<false>*)
  {
     return true;
  }
 -inline bool is_generic_tag_false(...)
 +inline bool is_generic_tag_false(const void*)
  {
     return false;
  }
 }}}

 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.
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6192>
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