Boost C++ Libraries: Ticket #3779: Warning using less_equal points to bug https://svn.boost.org/trac10/ticket/3779 <p> Compiling the following metafunction using VC9 gives a warning which suggests an mpl bug: </p> <p> #include &lt;boost/mpl/less_equal.hpp&gt; #include &lt;boost/mpl/long.hpp&gt; #include &lt;boost/integer_traits.hpp&gt; namespace nmspace { struct <a class="missing wiki">ResultTypeIntegerValues</a> </p> <blockquote> <p> { typedef boost::mpl::long_&lt;0L&gt; lzero; typedef boost::mpl::long_&lt;boost::integer_traits&lt;long&gt;::const_min&gt; lmin; typedef boost::mpl::less_equal&lt;lmin,lzero&gt;::type type; }; </p> </blockquote> <p> } </p> <p> with warning: </p> <p> c:\utilities\boost\boost_1_40_0\boost\mpl\aux_\integral_wrapper.hpp(73) : warning C4307: '-' : integral constant overflow 1&gt; 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_&lt;N&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; N=-2147483648 1&gt; ] 1&gt; 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&lt;T&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; T=nmspace::ResultTypeIntegerValues::lmin 1&gt; ] 1&gt; c:\programming\programs\xxx\yyy.h(64) : see reference to class template instantiation 'boost::mpl::less_equal&lt;N1,N2&gt;' being compiled 1&gt; with 1&gt; [ 1&gt; N1=nmspace::ResultTypeIntegerValues::lmin, 1&gt; N2=nmspace::ResultTypeIntegerValues::lzero 1&gt; ] </p> <p> The same warning occurs using Boost 1.41. As Steve Watanabe pointed out the problem looks to be: </p> <p> typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior; </p> <p> 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. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3779 Trac 1.4.3 Matthijs Kooijman <matthijs@…> Wed, 25 Apr 2018 09:22:18 GMT <link>https://svn.boost.org/trac10/ticket/3779#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3779#comment:1</guid> <description> <p> <a class="new ticket" href="https://svn.boost.org/trac10/ticket/6546" title="#6546: Bugs: mpl::constant_c does not support min and max values for signed types (new)">#6546</a> seems to be a duplicate of this bug. I just added some more info there, so it might be good to close this issue? </p> </description> <category>Ticket</category> </item> </channel> </rss>