[Rcpp-devel] compiler warning (-Wdelete-non-virtual-dtor)

romain at r-enthusiasts.com romain at r-enthusiasts.com
Sun Mar 10 20:33:13 CET 2013


thanks for the heads up. I will have a look at what needs to be done in 
a few days.

Romain

Le 2013-03-10 14:56, Greg Minshall a écrit :
> hi.  i normally build under macosx, but trying to track down a memory
> problem have started using (the wonderful) valgrind under linux.  the
> linux machine has a newer g++ (4.7.2 versus 4.2.1).  the compiler on 
> the
> linux machine was giving me warnings like:
> ----
> warning: deleting object of polymorphic class type
> ‘Rcpp::CppProperty<Num>’ which has non-virtual destructor might cause
> undefined behaviour
> ----
> (where "<Num>" varies between error messages).
>
> i started whittling down my program to a minimal case, but when i got
> near the null set, took a different approach.  i used the normal 
> tools
> to build a skeleton:
> ----
> /sw/Library/Frameworks/R.framework/Versions/2.15/Resources/Rscript -e 
> \
>     'Rcpp::Rcpp.package.skeleton(name="play", path="packages", \
>     attributes=TRUE, module=TRUE)'
> /sw/Library/Frameworks/R.framework/Versions/2.15/Resources/Rscript -e 
> \
>     'Rcpp::compileAttributes("packages/play")'
> R CMD build packages/play/
> ----
> i then copied this to the linux machine, tried installing it, and got
> the same (sorts of) error messages (see below).
>
> note that my ~/.R/Makevars contains:
> ----
> ## http://stackoverflow.com/a/11363085/1527747 (thanks, Dirk!)
> CXXFLAGS=-g -O0 -Wall
> ----
>
> since this is C++ at a level beyond my pay grade, i'm wondering what 
> to
> make of it.  any thoughts?  (in the case of my code, there is *some*
> correlation between the sites producing these warnings and the sites
> where valgrind finds memory irregularities, but that may be
> coincidental.)
>
> cheers, Greg
>
> ----
> bash whatever: {568} R CMD INSTALL --dsym play_1.0.tar.gz
> * installing to library 
> ‘/home/minshall/R/x86_64-pc-linux-gnu-library/2.15’
> * installing *source* package ‘play’ ...
> ** libs
> g++ -I/usr/share/R/include -DNDEBUG
> -I"/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include"
> -fpic  -g -O0 -Wall -c Num.cpp -o Num.o
> In file included from
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:48:0,
>                  from Num.cpp:22:
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/XPtr.h:
> In instantiation of ‘void Rcpp::standard_delete_finalizer(T*) [with T
> = Rcpp::CppProperty<Num>]’:
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/Module.h:313:13:
>   required from
> ‘Rcpp::S4_field<Class>::S4_field(Rcpp::CppProperty<Class>*, SEXP)
> [with Class = Num; SEXP = SEXPREC*]’
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/module/class.h:392:17:
>   required from ‘Rcpp::List Rcpp::class_<Class>::fields(SEXP) [with
> Class = Num; Rcpp::List = Rcpp::Vector<19>; SEXP = SEXPREC*]’
> Num.cpp:51:1:   required from here
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/XPtr.h:39:5:
> warning: deleting object of polymorphic class type
> ‘Rcpp::CppProperty<Num>’ which has non-virtual destructor might cause
> undefined behaviour [-Wdelete-non-virtual-dtor]
> g++ -I/usr/share/R/include -DNDEBUG
> -I"/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include"
> -fpic  -g -O0 -Wall -c RcppExports.cpp -o RcppExports.o
> g++ -I/usr/share/R/include -DNDEBUG
> -I"/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include"
> -fpic  -g -O0 -Wall -c rcpp_hello_world.cpp -o rcpp_hello_world.o
> g++ -I/usr/share/R/include -DNDEBUG
> -I"/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include"
> -fpic  -g -O0 -Wall -c rcpp_module.cpp -o rcpp_module.o
> In file included from
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:48:0,
>                  from rcpp_module.cpp:22:
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/XPtr.h:
> In instantiation of ‘void Rcpp::standard_delete_finalizer(T*) [with T
> = Rcpp::CppProperty<World>]’:
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/Module.h:313:13:
>   required from
> ‘Rcpp::S4_field<Class>::S4_field(Rcpp::CppProperty<Class>*, SEXP)
> [with Class = World; SEXP = SEXPREC*]’
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/module/class.h:392:17:
>   required from ‘Rcpp::List Rcpp::class_<Class>::fields(SEXP) [with
> Class = World; Rcpp::List = Rcpp::Vector<19>; SEXP = SEXPREC*]’
> rcpp_module.cpp:83:1:   required from here
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/XPtr.h:39:5:
> warning: deleting object of polymorphic class type
> ‘Rcpp::CppProperty<World>’ which has non-virtual destructor might
> cause undefined behaviour [-Wdelete-non-virtual-dtor]
> g++ -I/usr/share/R/include -DNDEBUG
> -I"/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include"
> -fpic  -g -O0 -Wall -c stdVector.cpp -o stdVector.o
> In file included from
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:48:0,
>                  from stdVector.cpp:22:
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/XPtr.h:
> In instantiation of ‘void Rcpp::standard_delete_finalizer(T*) [with T
> = Rcpp::CppProperty<std::vector<double> >]’:
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/Module.h:313:13:
>   required from
> ‘Rcpp::S4_field<Class>::S4_field(Rcpp::CppProperty<Class>*, SEXP)
> [with Class = std::vector<double>; SEXP = SEXPREC*]’
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/module/class.h:392:17:
>   required from ‘Rcpp::List Rcpp::class_<Class>::fields(SEXP) [with
> Class = std::vector<double>; Rcpp::List = Rcpp::Vector<19>; SEXP =
> SEXPREC*]’
> stdVector.cpp:90:1:   required from here
> 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/include/Rcpp/XPtr.h:39:5:
> warning: deleting object of polymorphic class type
> ‘Rcpp::CppProperty<std::vector<double> >’ which has non-virtual
> destructor might cause undefined behaviour 
> [-Wdelete-non-virtual-dtor]
> g++ -shared -o play.so Num.o RcppExports.o rcpp_hello_world.o
> rcpp_module.o stdVector.o
> -L/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/lib -lRcpp
> -Wl,-rpath,/home/minshall/R/x86_64-pc-linux-gnu-library/2.15/Rcpp/lib
> -L/usr/lib/R/lib -lR
> installing to 
> /home/minshall/R/x86_64-pc-linux-gnu-library/2.15/play/libs
> ** R
> ** preparing package for lazy loading
> ** help
> Warning:
> /tmp/RtmpV5N6bo/R.INSTALLe88448c4569/play/man/play-package.Rd:31: All
> text must be in a section
> Warning:
> /tmp/RtmpV5N6bo/R.INSTALLe88448c4569/play/man/play-package.Rd:32: All
> text must be in a section
> *** installing help indices
> ** building package indices
> ** testing if installed package can be loaded
>
> * DONE (play)
> bash whatever: {569} g++ --version
> g++ (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
> Copyright (C) 2012 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There 
> is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
> PURPOSE.
> _______________________________________________
> 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



More information about the Rcpp-devel mailing list