Hmmm. I think you just need "i<n" instead of "i<=n" in your for construct.
Romain Le 8 avr. 2011 à 10:12 AM, Cedric Ginestet <[email protected]> a écrit : > Hi guys, > > I have encountered a reproducible error in using Rcpp, which I have reported > below. Basically, while allocation of elements in a vector to a particular > value works well for vectors of small sizes, this returns an error when the > size of that vector is increased. Either it returns a giblc error or it hangs > and never resumes. I have reproduced this error on two different Linux > distributions (Ubuntu 10.10 and 10.04 with g++ 4.4.1 and R 2.12.1). > > #################################################### > library(Rcpp) > library(inline) > > src <- ' > Rcpp::IntegerMatrix xA(A); > int n=xA.nrow(); > NumericVector dist(n); > for(int i=0;i<=n;i++){dist[i]=1.0;} > return dist;' > cxxfun <- > cxxfunction(sig=signature(A="matrix"),body=src,plugin="Rcpp",verbose=TRUE) > > ## Tests. > n <- 20; A <- matrix(0,n,n); dist <- cxxfun(A); > n <- 200; A <- matrix(0,n,n); dist <- cxxfun(A); > n <- 2000; A <- matrix(0,n,n); dist <- cxxfun(A); > *** glibc detected *** /usr/lib/R/bin/exec/R: double free or corruption > (!prev): 0x08cfc278 *** > > #################################################### > > Is there something that I doing wrong there? > Thank you very much for your help, > Ced > > > -- > Cedric Ginestet > Centre for Neuroimaging Sciences (L3.04) > NIHR Biomedical Research Centre > Institute of Psychiatry, Box P089 > Kings College London > De Crespigny Park > London > SE5 8AF > _______________________________________________ > Rcpp-devel mailing list > [email protected] > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
_______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
