Clang and isnan compile error?

142 views
Skip to first unread message

Tor Arne Øigård

unread,
Sep 23, 2020, 4:28:47 AM9/23/20
to tmb-...@googlegroups.com

Hi,

 

I have a TMB code which has been developed in a Windows environment and works perfectly well there. I was going to test it under Linux but then it would not compile and it seemed to complain about some usage of isnan(). I have a .R folder containing a Makevars file where it is specified to use clang as a compiler, i.e., CXX=clang++ as (please correct me if I’m wrong) I recall there were some issues when loading the libraries after changes had been made in the cpp-file due to the gcc compiler. However, if I remove the .R folder and compile with the default gcc it compiles fine, but then I guess it still is the issue about the libraries.

 

Any ideas of what could be the problem? I suspect it has something to do with the clang version, as I found in another post someone mentioning a clang version much higher than installed on our system.

 

We are running:

 

Ubuntu 16.04 LTS

R 3.6.2

TMB 1.7.18

Clang 3.8.0-2ubuntu4

g++ (Ubuntu 4.9.3-13ubuntu2) 4.9.3

 

Kind regards,

Tor Arne

boen...@gmail.com

unread,
Sep 23, 2020, 5:34:25 AM9/23/20
to TMB Users
What error message are you getting? It sound like https://stackoverflow.com/q/39130040/5861244 as it compiles fine with g++ 4.9.3.

torarne...@gmail.com

unread,
Sep 25, 2020, 3:40:05 AM9/25/20
to TMB Users
Hi,

Thanks for the link. When trying to compile with clang it spits out a very long message. Below is some of the "highlights" that appears:


In file included from ../mycoder.cpp:71:
In file included from  /Rlibs/TMB/include/TMB.hpp:53:
In file included from /Rlibs/RcppEigen/include/Eigen/Dense:1:
In file included from /Rlibs/RcppEigen/include/Eigen/Core:535:
/Rlibs/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                             ^
In file included from /Rlibs/RcppEigen/include/Eigen/IterativeLinearSolvers:46:
/Rlibs/RcppEigen/include/Eigen/src/Core/util/ReenableStupidWarnings.h:10:30: warning: pragma diagnostic pop could not pop, no matching push [-Wunknown-pragmas]
    #pragma clang diagnostic pop
                 

/Rlibs/TMB/include/TMB.hpp:89:44: error: call to 'isnan' is ambiguous
  bool isnan(const AD<T> &x)CSKIP({ return isnan(Value(x)); })
  
/Rlibs/TMB/include/cppad/local/base_complex.hpp:361:14: note: candidate function
        inline bool isnan(const std::complex<float>& z)
                    ^
../mycode.cpp:157:6: error: call to 'isnan' is ambiguous

make: *** [../mycode.o] Error 1
Error in compile("../mycode.cpp") : Compilation failed

Not sure if this makes any sense. As I said compiling when removing the Makevars file works fine (but might have some issues with loading of libraries).

Best wishes,
Tor Arne

Kasper Kristensen

unread,
Sep 25, 2020, 4:39:25 AM9/25/20
to TMB Users
If it works with GCC but your main concern is library unloading I recommend you follow the instructions here:

https://github.com/kaskr/adcomp#issues-with-library-unloading

I.e., modify your Makevars to 'CXX = g++ -fno-gnu-unique'.

You may want to test that library unloading works by running this R script:
https://github.com/kaskr/adcomp/blob/master/tmb_syntax/test_reload.R


On Wednesday, September 23, 2020 at 10:28:47 AM UTC+2 torarne...@gmail.com wrote:

torarne...@gmail.com

unread,
Sep 28, 2020, 3:37:13 AM9/28/20
to TMB Users
Hi,

Thanks for this advice! The script works and it seems like the library unloads as it should. Appreciate this.

Best,
Tor Arne
Reply all
Reply to author
Forward
0 new messages