Skip one more test on macOS by eddelbuettel · Pull Request #1324 · RcppCore/Rcpp (original) (raw)
Looking at the sugar code, we try to cast R_PosInf
to the appropriate storage type here:
R_xlen_t n = obj.size(); |
---|
if (n == 0) return(static_cast(R_PosInf)); |
Distilling this into a smaller example, I used:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
SEXP casting_test() {
int value = static_cast<int>(R_PosInf);
return Rf_ScalarInteger(value);
}
/*** R
casting_test()
*/
On my ARM macOS machine:
$ R -s -e 'Rcpp::sourceCpp("abc.cpp")'
> casting_test()
[1] 2147483647
And on an x86_64 Docker image:
root@f00a2fde26d3:~/scratch# R -s -e 'Rcpp::sourceCpp("test.cpp")'
> casting_test()
[1] NA
And some StackOverflow searching suggests that attempting to cast INFINITY
to an integer is undefined behavior, e.g. https://stackoverflow.com/questions/38795544/is-casting-of-infinity-to-integer-undefined.
To wit -- should we just return NA
here? (if the storage type is not double
)