Seemingly starting with the most recent builds of R-devel, I�ve been getting 
segfaults related to a piece of cpp code that indexes a zero-size 
NumericVector.  Essentially the same as this dummy example:

```
library(Rcpp)

sourceCpp(
  code = '
  #include<Rcpp.h>
  using namespace Rcpp;

  // [[Rcpp::export]]
  NumericVector zeroindex() {
    NumericVector zerosize(0);

    Rcout << zerosize[0] << std::endl;

    return zerosize;
  }
  '
)

zeroindex()
```

On R-release and on previous builds, this returns something like:

```
6.92674e-310
numeric(0)
```

But on current R-devel containers:

```

 *** caught segfault ***

address 0x1, cause 'memory not mapped'



Traceback:

 1: .Call(<pointer: 0x7fa9369c7930>)

 2: zeroindex()



Possible actions:

1: abort (with core dump, if enabled)

2: normal R exit

3: exit R without saving workspace

4: exit R saving workspace
```

It was easy enough to write a catch for the zero-size vector, however I�m 
wondering why the discrepancy between R-devel and previous versions?

Best,
-DMC

        [[alternative HTML version deleted]]

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to