If I had a Mac, I would. But I am not much use when I have to borrow someone else’s machine (that has Catalina) to respond to posts with test cases.
I can say that
Rcpp::sourceCpp(code =
'
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int throw_exception() {
std::stringstream errmsg; errmsg << "this is an exception";
throw std::domain_error(errmsg.str());
return 0;
}
'
)
throw_exception()
works correctly (i.e. says “this is an exception”) if
- One uses
clang++
on Linux - One uses homebrew’s R on a Mac with Catalina
- One uses Xcode’s
clang++
on a Mac with Catalina, provided no other C++ packages from CRAN have previously been loaded
And the problem has not much to do with Stan, except that we call Rcpp::sourceCpp
and inline::cxxfunction
and throw exceptions at runtime. But even packages like rstanarm wiith Stan programs that are compiled in advance on CRAN are affected.