title: Why does assert not work here?
body: <p>Here is the code:</p>
  
  <pre><code>#include &lt;Rcpp.h&gt;
  #include &lt;iostream&gt;
  #include &lt;assert.h&gt;
  #include &lt;stdio.h&gt;
  
  using namespace Rcpp;
  
  
  // [[Rcpp::export]]
  double eudist(NumericVector x, NumericVector y) {
      int nx = x.size();
      int ny = y.size();
      std::cout &lt;&lt; nx &lt;&lt; '\n' &lt;&lt; ny &lt;&lt; std::endl;
      assert(nx == ny);
  
      double dist=0;
      for(int i = 0; i &lt; nx; i++) {
          dist += pow(x[i] - y[i], 2);
      }
  
      return sqrt(dist);
  }
  </code></pre>
  
  <p>After sourcing it into R, I get the following result, apparently it does not abort when there is an error:</p>
  
  <pre><code>#////////////////////////////////////////////////////
  sourceCpp('x.cpp')
  #////////////////////////////////////////////////////
  eudist(c(0, 0), c(1, 1))
  2
  2
  [1] 1.4142
  #////////////////////////////////////////////////////
  eudist(c(0, 0), c(1, 1, 1))
  2
  3
  [1] 1.4142
  </code></pre>