[Rcpp-devel] Zero length vectors in R

Akhila Chowdary Kolla akhilakollasrinu424jf at gmail.com
Tue Jun 9 07:04:56 CEST 2020


Hello everyone,

I am trying to test a package binsegRcpp. I pass the size of max_segments
vector as zero it doesn't throw any segfault when I am trying to access the
zeroth index element. Instead gives a garbage value or error like negative
length vectors not allowed.
Rcpp::List rcpp_binseg_normal
(const Rcpp::NumericVector data_vec,
const Rcpp::IntegerVector max_segments) {
int kmax = max_segments[0];
 }
Link to the package:
https://github.com/tdhock/binsegRcpp/blob/master/src/rcpp_interface.cpp

How is a zero-length vector represented in R? Does it still store a pointer
to some location?
If so Is there a way to get this segfault detected. I tried using
rhub::check it doesn't give any error. I tried using sanitizers as well
still no luck.
Can someone please suggest a way to detect this in R.

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200608/43df7d4f/attachment.html>


More information about the Rcpp-devel mailing list