Boost logo

Boost :

Subject: [boost] [mpl] integral_c [type_traits] integral_constant limits
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-11-14 15:22:34


Hi,

I was testing Boost.Ratio with gcc-4.6 c++0x and I get some compile errors when instantiating

std::cout <<
    boost::mpl::integral_c<
            boost::intmax_t,
            boost::integer_traits<boost::intmax_t>::const_max
>::value ;

..\..\..\../boost/mpl/aux_/integral_wrapper.hpp: In instantiation of 'mpl_::integral_c<long long int, 0x7fffffffffffffffll>':
ratio_io\ratio_io.pass.cpp:24:6: instantiated from here
..\..\..\../boost/mpl/aux_/integral_wrapper.hpp:72:96: warning: integer overflow in expression [-Woverflow]
..\..\..\../boost/mpl/aux_/integral_wrapper.hpp:72:96: error: '-0x8000000000000000ll' is not a valid template argument for type 'long long int' because it is a non-constant expression
..\..\..\../boost/mpl/aux_/integral_wrapper.hpp:72:96: error: '-0x8000000000000000ll' is not a constant expression

integral_wrapper.hpp:72 contains

    typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value + 1)) ) next;

The same line pass with gcc-4.6, gcc-4.5 and gcc-4.5 c++0x with just a warning.

..\..\..\../boost/mpl/aux_/integral_wrapper.hpp: In instantiation of 'mpl_::integral_c<long long int, 0x7fffffffffffffffll>':
ratio_io\ratio_io.pass.cpp:23:6: instantiated from here
..\..\..\../boost/mpl/aux_/integral_wrapper.hpp:72:96: warning: integer overflow in expression [-Woverflow]

integral_c is by integral_constant, but integral_constant doesn't needs next a prior types.

This means that with the current implementation we can not use integral_constant with the max value of the type.

Do you think this is a bug in integral_constant?

Best,
_____________________
Vicente Juan Botet Escribá
http://viboes.blogspot.com/


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk