[boost][multiprecision] compile error with gcc 4.8.4
Please see the scenario below...am I doing something wrong or is this a gcc or multiprecision bug? Thanks, Rob Conde given the following code (multiPrecisionTest.cpp): #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t; int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; } -------------------------------------------------------------------------- g++ -std=c++0x -c multiPrecisionTest.cpp I get the following error: In file included from ./boost/multiprecision/cpp_int.hpp:1936:0, from multiPrecisionTest.cpp:1: ./boost/multiprecision/cpp_int/misc.hpp: In instantiation of ‘typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type boost::multiprecision::backends::eval_convert_to(R*, const boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; unsigned int MinBits1 = 128u; unsigned int MaxBits1 = 128u; boost::multiprecision::cpp_integer_type SignType1 = (boost::multiprecision::cpp_integer_type)1u; boost::multiprecision::cpp_int_check_type Checked1 = (boost::multiprecision::cpp_int_check_type)0u; Allocator1 = void; typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type = void]’: ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ multiPrecisionTest.cpp:10:54: required from here ./boost/multiprecision/cpp_int/misc.hpp:533:138: error: no type named ‘type’ in ‘struct boost::common_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ typedef typename common_type<R, typename cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>::local_limb_type>::type common_type; ^
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should: float128_t f(intVal); However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later. John.
Any luck? It would be great if there was a fix in boost 1.62. Thanks, Rob ________________________________ From: Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> Sent: Tuesday, August 16, 2016 7:11:07 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4 On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should: float128_t f(intVal); However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later. John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b... If the tests cycle OK, I'll try to get this into 1.62, but it's tight now. John.
Thanks,
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Thanks! Rob Conde ________________________________ From: Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> Sent: Thursday, August 18, 2016 12:14:06 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4 On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b... If the tests cycle OK, I'll try to get this into 1.62, but it's tight now. John.
Thanks,
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I tried with 1.62 beta and ran into the following problems: Building with std=c++98 for the following case: -------------------------------------------------------------------------------- #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t; void func() { int128_t iVal; float128_t floatVal(iVal.convert_to<float128_t>()); } -------------------------------------------------------------------------------- In file included from ./boost/type_traits/detail/common_type_impl.hpp:12:0, from ./boost/type_traits/common_type.hpp:18, from ./boost/multiprecision/cpp_int.hpp:22, from mpTest.cpp:1: ./boost/type_traits/detail/common_arithmetic_type.hpp: In instantiation of ‘class boost::type_traits_detail::common_arithmetic_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’: ./boost/type_traits/detail/common_type_impl.hpp:99:35: required from ‘struct boost::type_traits_detail::common_type_impl5<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:90:35: required from ‘struct boost::type_traits_detail::common_type_impl4<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:79:35: required from ‘struct boost::type_traits_detail::common_type_impl3<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:52:35: required from ‘struct boost::type_traits_detail::common_type_class<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:68:35: required from ‘struct boost::type_traits_detail::common_type_impl<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:133:37: required from ‘struct boost::type_traits_detail::common_type_decay_helper<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:139:37: required from ‘struct boost::common_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, void, void, void, void, void, void, void>’ ./boost/multiprecision/cpp_int/misc.hpp:547:138: required from ‘typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type boost::multiprecision::backends::eval_convert_to(R*, const boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; unsigned int MinBits1 = 128u; unsigned int MaxBits1 = 128u; boost::multiprecision::cpp_integer_type SignType1 = (boost::multiprecision::cpp_integer_type)1u; boost::multiprecision::cpp_int_check_type Checked1 = (boost::multiprecision::cpp_int_check_type)0u; Allocator1 = void; typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type = void]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:52: required from here ./boost/type_traits/detail/common_arithmetic_type.hpp:211:60: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>’, and ‘__int128 unsigned’) typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type; Building without a std specified I get the following case: -------------------------------------------------------------------------------- #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t; void func() { float128_t floatVal; int128_t roundedNanoseconds(floatVal.convert_to<int128_t>()); } -------------------------------------------------------------------------------- In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp: In instantiation of ‘void boost::multiprecision::default_ops::eval_convert_to(boost::multiprecision::default_ops::terminal<boost::multiprecision::number<B1, et> >*, const B2&) [with B1 = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; B2 = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u]’: ./boost/multiprecision/detail/default_ops.hpp:896:31: required from ‘void boost::multiprecision::default_ops::eval_convert_to(R*, const B&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; B = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:62: required from here ./boost/multiprecision/detail/default_ops.hpp:922:134: error: no matching function for call to ‘generic_interconvert(boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>&, const boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>&, boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >, boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >)’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ ./boost/multiprecision/detail/default_ops.hpp:922:134: note: candidates are: In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<0>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >’) to type ‘const mpl_::int_<0>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<1>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<2>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ Rob ________________________________ From: Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> Sent: Thursday, August 18, 2016 12:14:06 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4 On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b... If the tests cycle OK, I'll try to get this into 1.62, but it's tight now. John.
Thanks,
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 15/09/2016 17:20, Rob Conde wrote:
I tried with 1.62 beta and ran into the following problems:
I think this fixes these: https://github.com/boostorg/multiprecision/commit/b2108867c7415cc1ed28244843... Or at least it does for me, can you verify with your setup as well please? Whether there is time for this to make 1.62 is another matter.... John.
Building with std=c++98 for the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { int128_t iVal; float128_t floatVal(iVal.convert_to<float128_t>()); } --------------------------------------------------------------------------------
In file included from ./boost/type_traits/detail/common_type_impl.hpp:12:0, from ./boost/type_traits/common_type.hpp:18, from ./boost/multiprecision/cpp_int.hpp:22, from mpTest.cpp:1: ./boost/type_traits/detail/common_arithmetic_type.hpp: In instantiation of ‘class boost::type_traits_detail::common_arithmetic_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’: ./boost/type_traits/detail/common_type_impl.hpp:99:35: required from ‘struct boost::type_traits_detail::common_type_impl5<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:90:35: required from ‘struct boost::type_traits_detail::common_type_impl4<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:79:35: required from ‘struct boost::type_traits_detail::common_type_impl3<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:52:35: required from ‘struct boost::type_traits_detail::common_type_class<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:68:35: required from ‘struct boost::type_traits_detail::common_type_impl<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:133:37: required from ‘struct boost::type_traits_detail::common_type_decay_helper<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:139:37: required from ‘struct boost::common_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, void, void, void, void, void, void, void>’ ./boost/multiprecision/cpp_int/misc.hpp:547:138: required from ‘typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type boost::multiprecision::backends::eval_convert_to(R*, const boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; unsigned int MinBits1 = 128u; unsigned int MaxBits1 = 128u; boost::multiprecision::cpp_integer_type SignType1 = (boost::multiprecision::cpp_integer_type)1u; boost::multiprecision::cpp_int_check_type Checked1 = (boost::multiprecision::cpp_int_check_type)0u; Allocator1 = void; typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type = void]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:52: required from here ./boost/type_traits/detail/common_arithmetic_type.hpp:211:60: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>’, and ‘__int128 unsigned’) typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type;
Building without a std specified I get the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { float128_t floatVal;
int128_t roundedNanoseconds(floatVal.convert_to<int128_t>()); } --------------------------------------------------------------------------------
In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp: In instantiation of ‘void boost::multiprecision::default_ops::eval_convert_to(boost::multiprecision::default_ops::terminal<boost::multiprecision::number<B1, et> >*, const B2&) [with B1 = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; B2 = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u]’: ./boost/multiprecision/detail/default_ops.hpp:896:31: required from ‘void boost::multiprecision::default_ops::eval_convert_to(R*, const B&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; B = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:62: required from here ./boost/multiprecision/detail/default_ops.hpp:922:134: error: no matching function for call to ‘generic_interconvert(boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>&, const boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>&, boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >, boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >)’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ ./boost/multiprecision/detail/default_ops.hpp:922:134: note: candidates are: In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<0>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >’) to type ‘const mpl_::int_<0>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<1>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<2>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Thursday, August 18, 2016 12:14:06 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b...
If the tests cycle OK, I'll try to get this into 1.62, but it's tight now.
John.
Thanks,
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
The first case (int -> float) was fixed, but the second (float->int) wasn't. Rob ________________________________ From: Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> Sent: Friday, September 16, 2016 7:54:26 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4 On 15/09/2016 17:20, Rob Conde wrote:
I tried with 1.62 beta and ran into the following problems:
I think this fixes these: https://github.com/boostorg/multiprecision/commit/b2108867c7415cc1ed28244843... Or at least it does for me, can you verify with your setup as well please? Whether there is time for this to make 1.62 is another matter.... John.
Building with std=c++98 for the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { int128_t iVal; float128_t floatVal(iVal.convert_to<float128_t>()); } --------------------------------------------------------------------------------
In file included from ./boost/type_traits/detail/common_type_impl.hpp:12:0, from ./boost/type_traits/common_type.hpp:18, from ./boost/multiprecision/cpp_int.hpp:22, from mpTest.cpp:1: ./boost/type_traits/detail/common_arithmetic_type.hpp: In instantiation of ‘class boost::type_traits_detail::common_arithmetic_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’: ./boost/type_traits/detail/common_type_impl.hpp:99:35: required from ‘struct boost::type_traits_detail::common_type_impl5<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:90:35: required from ‘struct boost::type_traits_detail::common_type_impl4<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:79:35: required from ‘struct boost::type_traits_detail::common_type_impl3<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:52:35: required from ‘struct boost::type_traits_detail::common_type_class<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:68:35: required from ‘struct boost::type_traits_detail::common_type_impl<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:133:37: required from ‘struct boost::type_traits_detail::common_type_decay_helper<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:139:37: required from ‘struct boost::common_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, void, void, void, void, void, void, void>’ ./boost/multiprecision/cpp_int/misc.hpp:547:138: required from ‘typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type boost::multiprecision::backends::eval_convert_to(R*, const boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; unsigned int MinBits1 = 128u; unsigned int MaxBits1 = 128u; boost::multiprecision::cpp_integer_type SignType1 = (boost::multiprecision::cpp_integer_type)1u; boost::multiprecision::cpp_int_check_type Checked1 = (boost::multiprecision::cpp_int_check_type)0u; Allocator1 = void; typename boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value && boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type = void]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:52: required from here ./boost/type_traits/detail/common_arithmetic_type.hpp:211:60: error: no match for ternary ‘operator?:’ (operand types are ‘bool’, ‘boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>’, and ‘__int128 unsigned’) typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type;
Building without a std specified I get the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { float128_t floatVal;
int128_t roundedNanoseconds(floatVal.convert_to<int128_t>()); } --------------------------------------------------------------------------------
In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp: In instantiation of ‘void boost::multiprecision::default_ops::eval_convert_to(boost::multiprecision::default_ops::terminal<boost::multiprecision::number<B1, et> >*, const B2&) [with B1 = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; B2 = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u]’: ./boost/multiprecision/detail/default_ops.hpp:896:31: required from ‘void boost::multiprecision::default_ops::eval_convert_to(R*, const B&) [with R = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; B = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T = boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:62: required from here ./boost/multiprecision/detail/default_ops.hpp:922:134: error: no matching function for call to ‘generic_interconvert(boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>&, const boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>&, boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >, boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >)’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ ./boost/multiprecision/detail/default_ops.hpp:922:134: note: candidates are: In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<0>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >’) to type ‘const mpl_::int_<0>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<1>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<2>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type ‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’ boost::multiprecision::detail::generic_interconvert(result->value.backend(), backend, number_category<B1>(), number_category<B2>()); ^
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Thursday, August 18, 2016 12:14:06 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b...
If the tests cycle OK, I'll try to get this into 1.62, but it's tight now.
John.
Thanks,
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 16/09/2016 19:50, Rob Conde wrote:
The first case (int -> float) was fixed, but the second (float->int) wasn't.
Oh :( I fear this may have to stay broken for this release - what I need to do is devise a test case that tests conversion of everything-to-everything - and that's going to be a lot of permutations! John.
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Friday, September 16, 2016 7:54:26 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 15/09/2016 17:20, Rob Conde wrote:
I tried with 1.62 beta and ran into the following problems:
I think this fixes these: https://github.com/boostorg/multiprecision/commit/b2108867c7415cc1ed28244843...
Or at least it does for me, can you verify with your setup as well please?
Whether there is time for this to make 1.62 is another matter....
John.
Building with std=c++98 for the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { int128_t iVal; float128_t floatVal(iVal.convert_to<float128_t>()); }
--------------------------------------------------------------------------------
In file included from ./boost/type_traits/detail/common_type_impl.hpp:12:0, from ./boost/type_traits/common_type.hpp:18, from ./boost/multiprecision/cpp_int.hpp:22, from mpTest.cpp:1: ./boost/type_traits/detail/common_arithmetic_type.hpp: In instantiation of ‘class
boost::type_traits_detail::common_arithmetic_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’: ./boost/type_traits/detail/common_type_impl.hpp:99:35: required from ‘struct
boost::type_traits_detail::common_type_impl5<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:90:35: required from ‘struct
boost::type_traits_detail::common_type_impl4<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:79:35: required from ‘struct
boost::type_traits_detail::common_type_impl3<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:52:35: required from ‘struct
boost::type_traits_detail::common_type_class<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:68:35: required from ‘struct
boost::type_traits_detail::common_type_impl<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:133:37: required from ‘struct
boost::type_traits_detail::common_type_decay_helper<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned,
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:139:37: required from ‘struct
boost::common_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, void, void, void, void, void, void, void>’ ./boost/multiprecision/cpp_int/misc.hpp:547:138: required from ‘typename
boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value &&
boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type boost::multiprecision::backends::eval_convert_to(R*, const boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&) [with R =
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; unsigned int MinBits1 = 128u; unsigned int MaxBits1 = 128u; boost::multiprecision::cpp_integer_type SignType1 = (boost::multiprecision::cpp_integer_type)1u; boost::multiprecision::cpp_int_check_type Checked1 = (boost::multiprecision::cpp_int_check_type)0u; Allocator1 = void; typename
boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value &&
boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type = void]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:52: required from here ./boost/type_traits/detail/common_arithmetic_type.hpp:211:60: error: no match for ternary ‘operator?:’ (operand types are ‘bool’,
‘boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>’, and ‘__int128 unsigned’) typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type;
Building without a std specified I get the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { float128_t floatVal;
int128_t roundedNanoseconds(floatVal.convert_to<int128_t>()); }
--------------------------------------------------------------------------------
In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp: In instantiation of ‘void
boost::multiprecision::default_ops::eval_convert_to(boost::multiprecision::default_ops::terminal<boost::multiprecision::number<B1,
et> >*, const B2&) [with B1 = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; B2 = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u]’: ./boost/multiprecision/detail/default_ops.hpp:896:31: required from ‘void boost::multiprecision::default_ops::eval_convert_to(R*, const B&) [with R =
boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; B = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:62: required from here ./boost/multiprecision/detail/default_ops.hpp:922:134: error: no matching function for call to
‘generic_interconvert(boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>&, const boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>&,
boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >,
boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >)’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ ./boost/multiprecision/detail/default_ops.hpp:922:134: note: candidates are: In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<0>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >’) to type ‘const mpl_::int_<0>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<1>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<2>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Thursday, August 18, 2016 12:14:06 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in
https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b...
If the tests cycle OK, I'll try to get this into 1.62, but it's
tight now.
John.
Thanks,
Rob
------------------------------------------------------------------------
*From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 17/09/2016 11:59, John Maddock wrote:
On 16/09/2016 19:50, Rob Conde wrote:
The first case (int -> float) was fixed, but the second (float->int) wasn't.
Oh :(
I fear this may have to stay broken for this release - what I need to do is devise a test case that tests conversion of everything-to-everything - and that's going to be a lot of permutations!
On second thoughts, the second case (float -> int) is a conversion we have never supported (unsafe/lossy) - which is to say this is by design. That said, we have always supported conversion to native (built-in) integer types, so we're inconsistent there. John.
John.
Rob
------------------------------------------------------------------------ *From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Friday, September 16, 2016 7:54:26 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 15/09/2016 17:20, Rob Conde wrote:
I tried with 1.62 beta and ran into the following problems:
I think this fixes these: https://github.com/boostorg/multiprecision/commit/b2108867c7415cc1ed28244843...
Or at least it does for me, can you verify with your setup as well please?
Whether there is time for this to make 1.62 is another matter....
John.
Building with std=c++98 for the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { int128_t iVal; float128_t floatVal(iVal.convert_to<float128_t>()); }
--------------------------------------------------------------------------------
In file included from ./boost/type_traits/detail/common_type_impl.hpp:12:0, from ./boost/type_traits/common_type.hpp:18, from ./boost/multiprecision/cpp_int.hpp:22, from mpTest.cpp:1: ./boost/type_traits/detail/common_arithmetic_type.hpp: In instantiation of ‘class
boost::type_traits_detail::common_arithmetic_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’: ./boost/type_traits/detail/common_type_impl.hpp:99:35: required from ‘struct
boost::type_traits_detail::common_type_impl5<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:90:35: required from ‘struct
boost::type_traits_detail::common_type_impl4<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:79:35: required from ‘struct
boost::type_traits_detail::common_type_impl3<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:52:35: required from ‘struct
boost::type_traits_detail::common_type_class<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/detail/common_type_impl.hpp:68:35: required from ‘struct
boost::type_traits_detail::common_type_impl<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:133:37: required from ‘struct
boost::type_traits_detail::common_type_decay_helper<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned,
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned>’ ./boost/type_traits/common_type.hpp:139:37: required from ‘struct
boost::common_type<boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>, __int128 unsigned, void, void, void, void, void, void, void>’ ./boost/multiprecision/cpp_int/misc.hpp:547:138: required from ‘typename
boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value &&
boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type boost::multiprecision::backends::eval_convert_to(R*, const boost::multiprecision::backends::cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>&) [with R =
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; unsigned int MinBits1 = 128u; unsigned int MaxBits1 = 128u; boost::multiprecision::cpp_integer_type SignType1 = (boost::multiprecision::cpp_integer_type)1u; boost::multiprecision::cpp_int_check_type Checked1 = (boost::multiprecision::cpp_int_check_type)0u; Allocator1 = void; typename
boost::enable_if_c<(boost::multiprecision::backends::is_trivial_cpp_int<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value &&
boost::multiprecision::is_signed_number<boost::multiprecision::backends::cpp_int_backend<MinBits1,
MaxBits1, SignType1, Checked1, Allocator1> >::value)>::type = void]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>; Backend = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:52: required from here ./boost/type_traits/detail/common_arithmetic_type.hpp:211:60: error: no match for ternary ‘operator?:’ (operand types are ‘bool’,
‘boost::multiprecision::number<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>, (boost::multiprecision::expression_template_option)0u>’, and ‘__int128 unsigned’) typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type;
Building without a std specified I get the following case:
--------------------------------------------------------------------------------
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void func() { float128_t floatVal;
int128_t roundedNanoseconds(floatVal.convert_to<int128_t>()); }
--------------------------------------------------------------------------------
In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp: In instantiation of ‘void
boost::multiprecision::default_ops::eval_convert_to(boost::multiprecision::default_ops::terminal<boost::multiprecision::number<B1,
et> >*, const B2&) [with B1 = boost::multiprecision::backends::cpp_int_backend<128u, 128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>; B2 = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option et = (boost::multiprecision::expression_template_option)0u]’: ./boost/multiprecision/detail/default_ops.hpp:896:31: required from ‘void boost::multiprecision::default_ops::eval_convert_to(R*, const B&) [with R =
boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; B = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>]’ ./boost/multiprecision/number.hpp:585:40: required from ‘void boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to_imp(T*) const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ ./boost/multiprecision/number.hpp:601:29: required from ‘T boost::multiprecision::number<Backend, ExpressionTemplates>::convert_to() const [with T =
boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >; Backend = boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>; boost::multiprecision::expression_template_option ExpressionTemplates = (boost::multiprecision::expression_template_option)0u]’ mpTest.cpp:11:62: required from here ./boost/multiprecision/detail/default_ops.hpp:922:134: error: no matching function for call to
‘generic_interconvert(boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void>&, const boost::multiprecision::backends::cpp_bin_float<113u, (boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383>&,
boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >,
boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >)’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ ./boost/multiprecision/detail/default_ops.hpp:922:134: note: candidates are: In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:30:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<0>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_integer>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:78:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_bin_float<113u,
(boost::multiprecision::backends::digit_base_type)2u, void, short int, -16382, 16383> >’) to type ‘const mpl_::int_<0>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<1>&, const mpl_::int_<1>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_floating_point>& /*to_type*/, const mpl::int_<number_kind_floating_point>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:126:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<1>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<2>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_rational>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:209:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^ In file included from ./boost/multiprecision/number.hpp:22:0, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template<class To, class From> void boost::multiprecision::detail::generic_interconvert(To&, const From&, const mpl_::int_<2>&, const mpl_::int_<0>&) void generic_interconvert(To& to, const From& from, const mpl::int_<number_kind_rational>& /*to_type*/, const mpl::int_<number_kind_integer>& /*from_type*/) ^ ./boost/multiprecision/detail/generic_interconvert.hpp:220:6: note: template argument deduction/substitution failed: In file included from ./boost/multiprecision/detail/generic_interconvert.hpp:9:0, from ./boost/multiprecision/number.hpp:22, from ./boost/multiprecision/cpp_int.hpp:12, from mpTest.cpp:1: ./boost/multiprecision/detail/default_ops.hpp:922:134: note: cannot convert
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >()’ (type
‘boost::multiprecision::number_category<boost::multiprecision::backends::cpp_int_backend<128u,
128u, (boost::multiprecision::cpp_integer_type)1u, (boost::multiprecision::cpp_int_check_type)0u, void> >’) to type ‘const mpl_::int_<2>&’
boost::multiprecision::detail::generic_interconvert(result->value.backend(),
backend, number_category<B1>(), number_category<B2>()); ^
Rob
------------------------------------------------------------------------
*From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Thursday, August 18, 2016 12:14:06 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 18/08/2016 15:05, Rob Conde wrote:
Any luck? It would be great if there was a fix in boost 1.62.
Fixed in
https://github.com/boostorg/multiprecision/commit/339818c0180d0719852b3e648b...
If the tests cycle OK, I'll try to get this into 1.62, but it's
tight now.
John.
Thanks,
Rob
------------------------------------------------------------------------
*From:* Boost-users <boost-users-bounces@lists.boost.org> on behalf of John Maddock <jz.maddock@googlemail.com> *Sent:* Tuesday, August 16, 2016 7:11:07 AM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4
On 16/08/2016 01:59, Rob Conde wrote:
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
int main() { int128_t intVal; float128_t floatVal(intVal.convert_to<float128_t>()); return 0; }
That should work, as should:
float128_t f(intVal);
However, while both of these do work with msvc, they fail with GCC, so there is a bug (or 2) somewhere. I'll investigate later.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 16/09/2016 19:50, Rob Conde wrote: The first case (int -> float) was fixed, but the second (float->int) wasn't. Oh :( I fear this may have to stay broken for this release - what I need to do is devise a test case that tests conversion of everything-to-everything - and that's going to be a lot of permutations! On second thoughts, the second case (float -> int) is a conversion we have never supported (unsafe/lossy) - which is to say this is by design. That said, we have always supported conversion to native (built-in) integer types, so we're inconsistent there. John. Can you clarify your approach going forward? When this compiles (other versions of gcc, visual studio) it works as intended. It's not a huge deal for me whether this is fixed for 1.62, but I definitely don't want it to be expressly forbidden going forward. Rob
Can you clarify your approach going forward? When this compiles (other versions of gcc, visual studio) it works as intended. It's not a huge deal for me whether this is fixed for 1.62, but I definitely don't want it to be expressly forbidden going forward.
The float->int conversion fails for me with as expected with msvc and current gcc versions. Of course the error message should be a lot better. The ideal solution would be to overload iround/itrunc for multiprecision integer target types, but of course that's not possible. I guess an explicit cast is just about acceptable, but let me think about this. John.
The float->int conversion fails for me with as expected with msvc and current gcc versions. Of course the error message should be a lot better. When you say "fail" do you mean at compile time or runtime? Rob
The following works with me in visual studio with toolset v120 and v140. #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <iostream> typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t; void main() { float128_t floatVal("6.0"); int128_t iVal(floatVal.convert_to<int128_t>()); std::cout << iVal << std::endl; } If I change it to have a fractional component, then indeed I get an exception...maybe that's what you mean. I personally only need the above behavior (though keeping the c++ truncation semantics might make sense as a long term goal...but i digress). I always floor/ceil because call convert_to<int128_t>(). Using boost 1.61 and gcc version 4.4.7, the above also compiles and works. Rob
On 17/09/2016 18:35, Rob Conde wrote:
The following works with me in visual studio with toolset v120 and v140.
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <iostream>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void main() { float128_t floatVal("6.0");
int128_t iVal(floatVal.convert_to<int128_t>());
std::cout << iVal << std::endl; }
If I change it to have a fractional component, then indeed I get an exception...maybe that's what you mean. I personally only need the above behavior (though keeping the c++ truncation semantics might make sense as a long term goal...but i digress). I always floor/ceil because call convert_to<int128_t>().
Using boost 1.61 and gcc version 4.4.7, the above also compiles and works.
OK, I see that compiles with 1.61, it does not with current master though (what will be 1.62). In 1.61 the code performs a lexical_cast for the conversion - that works more or less by accident for small integers, but for large ones it fails at runtime (as an exception) as the numbers get printed in scientific format during the lexical_cast. Conversion to long long works fine though, and probably in all the cases that your conversion to int128_t does. As I said, I need to figure out some more consistent behaviour for future releases. John.
Understood...thanks for your effort. Rob Conde Sent from my iPhone On Sep 17, 2016, at 2:43 PM, John Maddock <jz.maddock@googlemail.com<mailto:jz.maddock@googlemail.com>> wrote: On 17/09/2016 18:35, Rob Conde wrote: The following works with me in visual studio with toolset v120 and v140. #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <iostream> typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t; void main() { float128_t floatVal("6.0"); int128_t iVal(floatVal.convert_to<int128_t>()); std::cout << iVal << std::endl; } If I change it to have a fractional component, then indeed I get an exception...maybe that's what you mean. I personally only need the above behavior (though keeping the c++ truncation semantics might make sense as a long term goal...but i digress). I always floor/ceil because call convert_to<int128_t>(). Using boost 1.61 and gcc version 4.4.7, the above also compiles and works. OK, I see that compiles with 1.61, it does not with current master though (what will be 1.62). In 1.61 the code performs a lexical_cast for the conversion - that works more or less by accident for small integers, but for large ones it fails at runtime (as an exception) as the numbers get printed in scientific format during the lexical_cast. Conversion to long long works fine though, and probably in all the cases that your conversion to int128_t does. As I said, I need to figure out some more consistent behaviour for future releases. John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org<mailto:Boost-users@lists.boost.org> http://lists.boost.org/mailman/listinfo.cgi/boost-users
John, In the meantime, consider the following workaround: std::ostringstream o; o << std::fixed << std::setprecision(1) << tmp; int128_t roundedNanoseconds(o.str().substr(0,o.tellp() - std::streampos(2))); Does that seem reasonable, or do you see a much cleaner or efficient approach? Would be nicer to use setprecision(0), but: https://svn.boost.org/trac/boost/ticket/10103 Thanks for your input, Rob Conde ________________________________ From: Rob Conde Sent: Saturday, September 17, 2016 3:57:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4 Understood...thanks for your effort. Rob Conde Sent from my iPhone On Sep 17, 2016, at 2:43 PM, John Maddock <jz.maddock@googlemail.com<mailto:jz.maddock@googlemail.com>> wrote: On 17/09/2016 18:35, Rob Conde wrote: The following works with me in visual studio with toolset v120 and v140. #include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <iostream> typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t; void main() { float128_t floatVal("6.0"); int128_t iVal(floatVal.convert_to<int128_t>()); std::cout << iVal << std::endl; } If I change it to have a fractional component, then indeed I get an exception...maybe that's what you mean. I personally only need the above behavior (though keeping the c++ truncation semantics might make sense as a long term goal...but i digress). I always floor/ceil because call convert_to<int128_t>(). Using boost 1.61 and gcc version 4.4.7, the above also compiles and works. OK, I see that compiles with 1.61, it does not with current master though (what will be 1.62). In 1.61 the code performs a lexical_cast for the conversion - that works more or less by accident for small integers, but for large ones it fails at runtime (as an exception) as the numbers get printed in scientific format during the lexical_cast. Conversion to long long works fine though, and probably in all the cases that your conversion to int128_t does. As I said, I need to figure out some more consistent behaviour for future releases. John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org<mailto:Boost-users@lists.boost.org> http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 23/09/2016 19:13, Rob Conde wrote:
John,
In the meantime, consider the following workaround:
std::ostringstream o;
o << std::fixed << std::setprecision(1) << tmp;
int128_t roundedNanoseconds(o.str().substr(0,o.tellp() - std::streampos(2)));
Does that seem reasonable, or do you see a much cleaner or efficient approach?
Nod. As a temporary workaround that would work. Longer term a more efficient solution is to use ldexp/frexp to pull off N bits at a time.
Would be nicer to use setprecision(0), but:
Yes, I know. That's another one I need to work on / think about. Best, John.
Thanks for your input,
Rob Conde
------------------------------------------------------------------------ *From:* Rob Conde *Sent:* Saturday, September 17, 2016 3:57:39 PM *To:* boost-users@lists.boost.org *Subject:* Re: [Boost-users] [boost][multiprecision] compile error with gcc 4.8.4 Understood...thanks for your effort.
Rob Conde
Sent from my iPhone
On Sep 17, 2016, at 2:43 PM, John Maddock <jz.maddock@googlemail.com <mailto:jz.maddock@googlemail.com>> wrote:
On 17/09/2016 18:35, Rob Conde wrote:
The following works with me in visual studio with toolset v120 and v140.
#include <boost/multiprecision/cpp_int.hpp> #include <boost/multiprecision/cpp_bin_float.hpp> #include <iostream>
typedef boost::multiprecision::int128_t int128_t; typedef boost::multiprecision::cpp_bin_float_quad float128_t;
void main() { float128_t floatVal("6.0");
int128_t iVal(floatVal.convert_to<int128_t>());
std::cout << iVal << std::endl; }
If I change it to have a fractional component, then indeed I get an exception...maybe that's what you mean. I personally only need the above behavior (though keeping the c++ truncation semantics might make sense as a long term goal...but i digress). I always floor/ceil because call convert_to<int128_t>().
Using boost 1.61 and gcc version 4.4.7, the above also compiles and works.
OK, I see that compiles with 1.61, it does not with current master though (what will be 1.62).
In 1.61 the code performs a lexical_cast for the conversion - that works more or less by accident for small integers, but for large ones it fails at runtime (as an exception) as the numbers get printed in scientific format during the lexical_cast. Conversion to long long works fine though, and probably in all the cases that your conversion to int128_t does.
As I said, I need to figure out some more consistent behaviour for future releases.
John. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org <mailto:Boost-users@lists.boost.org> http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
John Maddock
-
Rob Conde