[Rcpp-devel] assert() for Rcpp?
jj.allaire at gmail.com
Wed Feb 18 17:31:29 CET 2015
We *can* call Rf_error from C++ code, but when we do it bypasses all
C++ destructors on the stack, so we don't do it so as not leak memory
and otherwise have deterministic behavior around
You'll notice in Dirk's example that there are no C++ objects on the
stack when he calls Rf_error. The core idea in Rcpp is to use
exceptions to get high enough in the stack that there are no more
On Wed, Feb 18, 2015 at 9:08 AM, Sparapani, Rodney <rsparapa at mcw.edu> wrote:
> On Tue, 2015-02-17 at 17:53 -0700, JJ Allaire wrote:
>> One piece of immediate feedback on your initial implementation: you
>> can't call Rf_error from C++ code (as it will bypass C++ destructors
>> on the stack). Rather, you should throw Rcpp::exception.
> Hi JJ:
> Ok, this puzzles me. We can't call Rf_error from C++ code, but we can
> call it from within the exception handler, right? It would seem so
> since Dirk has written a nice gallery post that does it that way...
> Just my $0.02, but I would stick to exceptions and avoid assert in C++.
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
More information about the Rcpp-devel