[Rcpp-devel] Module compilation warnings with clang++/llvm
Dirk Eddelbuettel
edd at debian.org
Fri Mar 22 01:11:25 CET 2013
Hi Rich,
On 22 March 2013 at 10:18, Rich FitzJohn wrote:
| Dear list,
|
| When I compile Rcpp modules with clang, I see a number of warnings that seem to come from Rcpp. Below is a small file containing a fairly useless module (test.cpp).
"Stuff happens" :)
| test.cpp:
|
| ---8<-----
|
| #include <Rcpp.h>
|
| class Foo {
| public:
| Foo(double a) : a(a) {}
| double run(double b) { return a+b; }
| private:
| double a;
| };
|
| RCPP_MODULE(test) {
| Rcpp::class_<Foo>("Foo")
| .constructor<double>()
| .method("run", &Foo::run);
| }
|
| ----->8---
|
|
| Compiling this with sourceRcpp (though obviously that won't finish because no attributes) or through R CMD SHLIB (with a local Makevars file following the Rcpp FAQ) generates warnings:
|
| clang++ -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -DNDEBUG -I/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include -Wall -ansi -pedantic -I/usr/local/include -fPIC -O2 -Wall -c test.cpp -o test.o
| In file included from test.cpp:1:
| In file included from /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp.h:48:
| /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/XPtr.h:39:5: warning: delete called on
| 'Rcpp::CppProperty<Foo>' that has virtual functions but non-virtual destructor [-Wdelete-non-virtual-dtor]
I think that one was just fixed in SVN a few days ago.
| delete obj ;
| ^
| /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/XPtr.h:50:44: note: in instantiation of function
| template specialization 'Rcpp::standard_delete_finalizer<Rcpp::CppProperty<Foo> >' requested here
| template <typename T, void Finalizer(T*) = standard_delete_finalizer<T> >
| ^
| /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/module/class.h:392:26: note: in instantiation of member
| function 'Rcpp::S4_field<Foo>::S4_field' requested here
| out[i] = S4_field<Class>( it->second, class_xp ) ;
| ^
| test.cpp:12:3: note: in instantiation of member function 'Rcpp::class_<Foo>::fields' requested here
| Rcpp::class_<Foo>("Foo")
| ^
| 1 warning generated.
| g++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o test.so test.o /Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/lib/x86_64/libRcpp.a -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
|
| If I increase the warnings to the level that CRAN are apparently using (changing CXXFLAGS to -O2 -Wall -pedantic -Wconversion) I get pages and pages of warnings (not pasted here). So far as I can see, these come from Rcpp, but if I'm doing anything wrong, I'd appreciate any pointers.
Well, patches are always welcome. I develop mostly with whatever g++ version
is current in the current Ubuntu release, right now g++ 4.7.2. I do use
-Wall -pedantic and try to keep it 'clean'. I simply don't use the compiler
you use all that much. So in that sense ... patches welcome.
Also, can you try the most current tarball from R-Forge [ goes checking ]
Grr, once again no tarball available. Could you test from SVN? Else I can
make the most recent tarball available from my site.
Dirk
| Versions and flag information below.
|
| Thanks,
| Rich
|
|
| Makevars contains:
| CXX=clang++
| CC=clang
| CXXFLAGS=-O2 -Wall
|
| Versions:
|
| Apple clang version 4.0 (tags/Apple/clang-421.0.57) (based on LLVM 3.1svn)
| Target: x86_64-apple-darwin12.2.1
| Thread model: posix
|
| Mac OS X 10.8 (Mountain Lion), Xcode 4.5.1
|
| sessionInfo:
| R version 2.15.3 (2013-03-01)
| Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
|
| locale:
| [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
|
| attached base packages:
| [1] stats graphics grDevices utils datasets methods base
|
| other attached packages:
| [1] Rcpp_0.10.2
|
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list