<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Hi guys, <br>
    <br>
    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). <br>
    <br>
    ####################################################<br>
    library(Rcpp)<br>
    library(inline)<br>
    <br>
    src &lt;- '<br>
    &nbsp; Rcpp::IntegerMatrix xA(A);<br>
    &nbsp; int n=xA.nrow();<br>
    &nbsp; NumericVector dist(n);<br>
    &nbsp; for(int i=0;i&lt;=n;i++){dist[i]=1.0;}<br>
    &nbsp; return dist;'<br>
    cxxfun &lt;-
cxxfunction(sig=signature(A="matrix"),body=src,plugin="Rcpp",verbose=TRUE)<br>
    <br>
    ## Tests.<br>
    n &lt;- 20; A &lt;- matrix(0,n,n); dist &lt;- cxxfun(A); <br>
    n &lt;- 200; A &lt;- matrix(0,n,n); dist &lt;- cxxfun(A); <br>
    n &lt;- 2000; A &lt;- matrix(0,n,n); dist &lt;- cxxfun(A); <br>
    *** glibc detected *** /usr/lib/R/bin/exec/R: double free or
    corruption (!prev): 0x08cfc278 ***<br>
    <br>
    ####################################################<br>
    <br>
    Is there something that I doing wrong there? <br>
    Thank you very much for your help, <br>
    Ced<br>
    <br>
    <br>
    <div class="moz-signature">-- <br>
      <div class="moz-signature"><font face="Times" size="3">
          Cedric Ginestet <br>
          Centre for Neuroimaging Sciences (L3.04) <br>
          NIHR Biomedical Research Centre <br>
          Institute of Psychiatry, Box P089 <br>
          Kings College London <br>
          De Crespigny Park<br>
          London <br>
          SE5 8AF <br>
        </font>
      </div>
    </div>
  </body>
</html>