dftlibs / xcfun

XCFun: A library of exchange-correlation functionals with arbitrary-order derivatives
https://dftlibs.org/xcfun/
Mozilla Public License 2.0
57 stars 32 forks source link

Build fails: error: call to 'cbrt' is ambiguous #22

Closed yurivict closed 7 years ago

yurivict commented 7 years ago

Getting this error on FreeBSD 11 (using clang):

/usr/ports/science/py-pyscf/work/pyscf-1.3.2/deps/src/libxcfun/src/functionals/pw92eps.h:21:13: error: call to 'cbrt' is ambiguous
    return (cbrt(2)/(cbrt(2)-1))*(d.a_43+d.b_43)*d.n_m13/d.n - 1/(cbrt(2)-1);
            ^~~~
/usr/include/c++/v1/math.h:988:1: note: candidate function [with _A1 = int]
cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);}
^
/usr/ports/science/py-pyscf/work/pyscf-1.3.2/deps/src/libxcfun/src/taylor/taylor_math.h:261:10: note: candidate function [with T = int]
inline T cbrt(T x)
         ^

One way to solve this is to replace cbrt with std::cbrt.

robertodr commented 7 years ago

Which version of Clang are you using? Have you tried using GNU compilers? I am afraid using std::cbrt is not the right solution here, we really want to use the data typed provided by libtaylor here, in order to have functional derivatives calculated with automatic differentiation, but I might be wrong and @uekstrom can definitely correct me. What happens if you pass 2.0 as argument to cbrt instead? Can you report for both Clang and GNU?

yurivict commented 7 years ago

Replacing 2 with 2.0 solves the problem. clang-4.0.0

robertodr commented 7 years ago

OK, I'd say let's keep the issue open until @uekstrom and/or others can comment too. Would you also be so kind as to file a pull request with these changes? Just so that we don't forget about this problem and its solution.