Closed radj307 closed 6 months ago
I'm encountering an error when trying to convert
Hi @radj307 great catch and thanks for the report.
I can reproduce this situation exactly with modular-boost on today's develop-branch as well.
The phenomenon seems to arise from detail/functions/trunc.hpp line 29.
The operator ?
mentioned is the ternary operator at that line where the arguments (i.e., the compiler's decuced result types from floor
and ceil
) differ. One is the backend type alone whereby the other is the fully number-wrapped backend type.
I was not, sadly, alone able to find the root cause.
But if it helps investigations, rewriting impl::trunc()
in the following way eliminates the problem. But this is not a great solution suggestoin. I'd like to see why the overloads have differences. But alone I couldn't figure it out (yet).
Another detail, this trunc
is called from lltrunc
in the same header around line 59. So that's probably closer to the place where the arguments for the overloads are determined, probably even higher upstream in the call chain actually.
template <typename T>
inline T trunc BOOST_PREVENT_MACRO_SUBSTITUTION (const T arg)
{
using std::floor;
using std::ceil;
T t { };
if (arg > T(0))
{
t = floor(arg);
}
else
{
t = ceil(arg);
}
return t;
}
Cc: @mborland and @jzmaddock
See also #587, which might not be the last word on this, but offers a preliminary (perhaps legitimate, long-lasting) fix.
Cc: @jzmaddock and @mborland
Fixed in #587
I'm using
cpp_int
andcpp_dec_float_100
in a project, but I'm encountering an error when trying to convert from float to int on both MSVC 19.34.31947 and gcc 10, using boostmp 1.84 standalone.This is the error message in GCC 10 (formatted for readability):
The error does not occur when using Boost::math alongside it.