[Boost-bugs] [Boost C++ Libraries] #9647: boost_MPL_ASSERT_RELATION fails to properly handle unsigned types

Subject: [Boost-bugs] [Boost C++ Libraries] #9647: boost_MPL_ASSERT_RELATION fails to properly handle unsigned types
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-02-09 21:00:37


#9647: boost_MPL_ASSERT_RELATION fails to properly handle unsigned types
------------------------------+----------------------
 Reporter: ramey | Owner: dlwalker
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: integer
  Version: Boost 1.54.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------
 boost/integer_traits.hpp contains the following
 {{{
 template<>
 class integer_traits<unsigned long>
   : public std::numeric_limits<unsigned long>,
     public detail::integer_traits_base<unsigned long, 0, ULONG_MAX>
 { };
 }}}

 Problem is that, at least on Clang ULONG_MAX resolves to (through
 <limits.h>) to be

 {{{
 #define ULONG_MAX (__LONG_MAX__ *2UL+1UL)
 }}}

 But when __LONG_MAX__ resolves to long and the rules of arithmetic
 promotion result in the expression
 __LONG_MAX__ *2UL+1UL being a long rather than unsigned long. This causes
 some funky behavior in cases like:

 {{{
 BOOST_MPL_ASSERT_RELATION(
     (boost::integer_traits<unsigned long>::const_max),
>,
     (boost::integer_traits<unsigned char>::const_max)
 );
 }}}

 which fails to compile with "Non-type template argument evaluates to
 4294967295, which cannot be narrowed to type 'long'

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