range-v3
range-v3 copied to clipboard
not a constant expression
I am compiling a project in Debug (CMake) mode. This projects uses ranges-v3, just updated from master branch. When trying to compile, it gives the following error
/home/user/usr/local/include/range/v3/iterator/diffmax_t.hpp:372:37: error: (6.5e+1 * 3.0102999600000002e-1) is not a constant expression
static_cast<int>(digits * 0.301029996); // digits * std::log10(2)
Is this normal? How should I fix it?
Note to future self: make range-v3 work with -frounding-math
.
The problem here is that I'm using CGAL and range-v3 for the same cmake target. CGAL includes -frounding-math
, which breaks range-v3.
I have fixed this by separating the target which uses CGAL and the target which uses range-v3.
I'll close the issue.
@ericniebler if I can help you in any way to fix this issue, I will be happy to do it
@ericniebler What do you think about using 643L / 2136
as an approximation for std::log10(2)
? (As far as I can see, this is how libstdc++
solves the problem.)
I'm happy to submit a pull request with this patch if this is helpful.