[Rcpp-devel] tracking volatile bug

Sokol Serguei serguei.sokol at gmail.com
Mon Nov 24 01:25:12 CET 2014


Martin Morgan has written at  Sun, 23 Nov 2014 14:09:27 -0800
> On 11/23/2014 11:07 AM, Sokol Serguei wrote:
>> Gabor Grothendieck has written at  Sat, 22 Nov 2014 19:17:27 -0500
>>> On Sat, Nov 22, 2014 at 1:43 PM, Sokol 
>>> Serguei<serguei.sokol at gmail.com>  wrote:
>>>> Let try to stick with regular rcpp code
>>>> (file: matrix_norm.cpp):
>>>>
>>>> //[[Rcpp::depends(RcppArmadillo)]]
>>>> #include <RcppArmadillo.h>
>>>> using namespace Rcpp;
>>>> using namespace arma;
>>>>
>>>> // [[Rcpp::export]]
>>>> double nmat(mat A) {
>>>>     Function Matrix_norm_r_=Environment("package:Matrix")["norm"];
>>>>     double res=as<double>(Matrix_norm_r_(A, "1"));
>>>>     return res;
>>>> }
...
> but obviously the other pairlist templates need protection, too. Maybe 
> it's enough, instead, to add protection to grow
>
>     template <typename T>
>     SEXP grow(const T& head, SEXP tail) {
>         Shield<SEXP> y(tail);
>         return internal::grow__dispatch( typename 
> traits::is_named<T>::type(), head, y );
>     }
>
>     inline SEXP grow( const char* head, SEXP tail ) {
>         Shield<SEXP> y(tail);
>         return grow( Rf_mkString(head), y ) ;
>     } 
I confirm that this patch solved the problem. Nice find Martin.

Serguei.


More information about the Rcpp-devel mailing list