Yes, there is an underlying pointer. You can simply test
'max_segments.size()' to see if you are allowed to dereference that
first element or not.
If you're interested in the exact R representation of vectors at
C-level, read R Internals
(https://cran.r-project.org/doc/manuals/r-release/R-ints.pdf).
If you are interested in the Rcpp wrappers around these vectors look at
the Rcpp header file 'vector.h' in the Rcpp package
(inst/include/Rcpp/vector/Vector.h).
On 6/9/20 1:04 AM, Akhila Chowdary Kolla wrote:
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
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel