[Boost-bugs] [Boost C++ Libraries] #3779: Warning using less_equal points to bug

Subject: [Boost-bugs] [Boost C++ Libraries] #3779: Warning using less_equal points to bug
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-12-19 07:18:18


#3779: Warning using less_equal points to bug
------------------------------------------------+---------------------------
 Reporter: Edward Diener <eld@…> | Owner: agurtovoy
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: mpl
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
------------------------------------------------+---------------------------
 Compiling the following metafunction using VC9 gives a warning which
 suggests an mpl bug:

 #include <boost/mpl/less_equal.hpp>
 #include <boost/mpl/long.hpp>
 #include <boost/integer_traits.hpp>
 namespace nmspace {
 struct ResultTypeIntegerValues
   {
   typedef boost::mpl::long_<0L> lzero;
   typedef boost::mpl::long_<boost::integer_traits<long>::const_min> lmin;
   typedef boost::mpl::less_equal<lmin,lzero>::type type;
   };
 }

 with warning:

 c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\integral_wrapper.hpp(73) :
 warning C4307: '-' : integral constant overflow
 1>
 c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\preprocessed\plain\less_equal.hpp(60)
 : see reference to class template instantiation 'boost::mpl::long_<N>'
 being compiled
 1> with
 1> [
 1> N=-2147483648
 1> ]
 1>
 c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\preprocessed\plain\less_equal.hpp(70)
 : see reference to class template instantiation
 'boost::mpl::less_equal_tag<T>' being compiled
 1> with
 1> [
 1> T=nmspace::ResultTypeIntegerValues::lmin
 1> ]
 1> c:\programming\programs\xxx\yyy.h(64) : see reference to class
 template instantiation 'boost::mpl::less_equal<N1,N2>' being compiled
 1> with
 1> [
 1> N1=nmspace::ResultTypeIntegerValues::lmin,
 1> N2=nmspace::ResultTypeIntegerValues::lzero
 1> ]

 The same warning occurs using Boost 1.41. As Steve Watanabe pointed out
 the problem looks to be:

 typedef AUX_WRAPPER_INST(
 BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;

 which overflows when one is already at the minimal value. It seems mpl has
 to take into account the minimal value when using prior and probably the
 maximal value when using next. In any case I see nothing wrong in the code
 and therefore I do not think an overflow condition should not be taking
 place.

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