range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

not a constant expression

Open jjcasmar opened this issue 5 years ago • 4 comments

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?

jjcasmar avatar Jan 22 '20 14:01 jjcasmar

Note to future self: make range-v3 work with -frounding-math.

ericniebler avatar Jan 23 '20 06:01 ericniebler

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.

jjcasmar avatar Jan 23 '20 09:01 jjcasmar

@ericniebler if I can help you in any way to fix this issue, I will be happy to do it

jjcasmar avatar Jan 23 '20 18:01 jjcasmar

@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.

m-8k avatar Mar 14 '22 13:03 m-8k