boostorg / interval

Boost.org numeric interval library
http://boost.org/libs/numeric/interval/doc
Boost Software License 1.0
24 stars 44 forks source link

Ill-formed narrowing conversions for ppc #29

Open jwakely opened 2 years ago

jwakely commented 2 years ago
/usr/include/boost/numeric/interval/detail/ppc_rounding_control.hpp:31:56: error: narrowing conversion of '18444492273895866370' from 'long long unsigned int' to 'boost::long_long_type' {aka 'long long int'} [-Wnarrowing]
   31 | static const rounding_mode_struct mode_upward      = { 0xFFF8000000000002LL };
      |                                                        ^~~~~~~~~~~~~~~~~~~~
/usr/include/boost/numeric/interval/detail/ppc_rounding_control.hpp:32:56: error: narrowing conversion of '18444492273895866371' from 'long long unsigned int' to 'boost::long_long_type' {aka 'long long int'} [-Wnarrowing]
   32 | static const rounding_mode_struct mode_downward    = { 0xFFF8000000000003LL };
      |                                                        ^~~~~~~~~~~~~~~~~~~~
/usr/include/boost/numeric/interval/detail/ppc_rounding_control.hpp:33:56: error: narrowing conversion of '18444492273895866368' from 'long long unsigned int' to 'boost::long_long_type' {aka 'long long int'} [-Wnarrowing]
   33 | static const rounding_mode_struct mode_to_nearest  = { 0xFFF8000000000000LL };
      |                                                        ^~~~~~~~~~~~~~~~~~~~
/usr/include/boost/numeric/interval/detail/ppc_rounding_control.hpp:34:56: error: narrowing conversion of '18444492273895866369' from 'long long unsigned int' to 'boost::long_long_type' {aka 'long long int'} [-Wnarrowing]
   34 | static const rounding_mode_struct mode_toward_zero = { 0xFFF8000000000001LL };
      |                                                        ^~~~~~~~~~~~~~~~~~~~

These constants are too large for long long so they have type unsigned long long (despite the LL suffix). Converting them to long long inside a braced-init-list is a narrowing conversion.