[Rcpp-devel] Module compilation warnings with clang++/llvm
Rich FitzJohn
rich.fitzjohn at gmail.com
Fri Mar 22 00:18:08 CET 2013
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).
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]
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.
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
More information about the Rcpp-devel
mailing list