0

I am having an issue compiling a project which uses ranges-v3. It complains an expression, which to me looks constant, is not constant.

[ 47%] Building CXX object src/foo.cpp.o
In file included from /home/jjcasmar/usr/local/include/range/v3/view/iota.hpp:29,
                 from /home/jjcasmar/usr/local/include/range/v3/view/indices.hpp:24,
                 from /home/jjcasmar/usr/local/include/range/v3/view.hpp:47,
                 from /home/jjcasmar/projects/project/src/foo.cpp:78:
/home/jjcasmar/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)
                              ~~~~~~~^~~~~~~~~~~~~
make[3]: *** [src/deSim/CMakeFiles/deSim.dir/build.make:1389: src/foo.cpp.o] Error 1

This happens using both gcc-8 and gcc-9 compiling with std=gnu++14 and with range-v3 master and 0.9.1 branches.

This used to work, but suddenly it has stopped working. What might be wrong?

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70
jjcasmar
  • 1,387
  • 1
  • 18
  • 30
  • 1
    How can we help you without seeing your code? [mcve] please. – Jesper Juhl Jan 22 '20 at 19:48
  • I am not sure what code I can show that has any relevance to this, as apparently the issue is inside range-v3, no? – jjcasmar Jan 22 '20 at 19:49
  • 4
    @jjcasmar It might be a usage issue. It might be a compilation issue. It might be a library bug. But its usually necessary to be able to reproduce the problem to solve it. – François Andrieux Jan 22 '20 at 19:51
  • Possibly related : [constexpr: errors with floating point representation?](https://stackoverflow.com/questions/20791333/constexpr-errors-with-floating-point-representation) – François Andrieux Jan 22 '20 at 19:51
  • "This used to work, but suddenly it has stopped working." - Then it's probably caused by a change you made. One (usually quite effective) approach to finding the problem would be to check out a version of your code from a while ago, from your revision control software (git, SVN, CVS, whatever); test if that works, and if it does, then bisect commits between then and now to find the commit/change that broke it. – Jesper Juhl Jan 22 '20 at 19:52
  • Why is this tagged with `cmake`? – Kevin Jan 22 '20 at 19:52
  • @jjcasmar "apparently the issue is inside range-v3, no?" - It could just as easily (actually *more* likely, I'd say) be an issue with how you *use* range-v3. – Jesper Juhl Jan 22 '20 at 19:55
  • apparently, it is an issue with CGAL. CGAL adds -frounding-math, which makes range-v3 fail. this is going to be funny to solve :) – jjcasmar Jan 22 '20 at 20:00
  • so I have solved this issue in a non optimal way. I have two static libs, one which uses CGAL, one which uses range-v3. The one using CGAL has a template which uses some CGAL stuff, so I need to expose CGAL headers on the header file. The static lib using range-v3 need to know where to find CGAL headers, so I was making CGAL a public dependency of the first static lib. This includes all CGAL flags in the second lib and triggers the issue. Fortunately, cgal and range-v3 are installed in the same directory, so it can still find CGAL headers without adding them. – jjcasmar Jan 22 '20 at 20:35

0 Answers0