Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort on R type error if debugging #860

merged 4 commits into from Jun 8, 2018


None yet
4 participants
Copy link

jackwasey commented Jun 5, 2018

Following discussion in #857 , this PR prints an error to standard error, and aborts, allowing a debugger to examine state leading up to the error, instead of dropping out of R. The assert macro didn't seem like the right tool, as it would never give an informative error message. The glibc assert macro calls abort, so I used it here, while checking for absence ofNDEBUG. The default build process in R is done with -DNDEBUG so this should not alter behavior for anyone who hasn't explicitly used -UNDEBUG, and therefore this should not impact any packages built for CRAN in the usual way.

There is no obvious way for me to add an automated test for this code, since it requires compiling with and without the NDEBUG flag set.

Jack O. Wasey

This comment has been minimized.


kevinushey Jun 5, 2018


#else instead of #elif?

This comment has been minimized.


jackwasey Jun 5, 2018

Author Contributor

Yes... whoops. But it worked with clang, so I missed it.

Jack O. Wasey

This comment has been minimized.

Copy link

codecov-io commented Jun 5, 2018

Codecov Report

Merging #860 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #860   +/-   ##
  Coverage    90.3%   90.3%           
  Files          70      70           
  Lines        3261    3261           
  Hits         2945    2945           
  Misses        316     316
Impacted Files Coverage Δ
inst/include/Rcpp/r_cast.h 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3c8558...e614d53. Read the comment docs.

@@ -67,9 +67,17 @@ namespace Rcpp {
const char* fmt = "Not compatible with requested type: "
"[type=%s; target=%s].";
#ifndef NDEBUG

This comment has been minimized.


eddelbuettel Jun 7, 2018


Should that not be REprintf() ?

This comment has been minimized.


jackwasey Jun 7, 2018

Author Contributor

I wasn't aware of REprintf, made the change.

I used the following to test:

Rcpp::cppFunction('void type_err(IntegerVector iv) {}')

Which aborts with the appropriate error message if I add -UNDEBUG in CXXFLAGS before compilation, otherwise gives normal Rcpp behavior.

This comment has been minimized.


eddelbuettel Jun 7, 2018


Thanks. REprintf() is one of those gems hidden away in WRE which "they" to nag you on submission. You know, like 'no stdout, no abort, ...' ;-)

Jack O. Wasey and others added some commits Jun 7, 2018

@eddelbuettel eddelbuettel merged commit 7dcda6d into RcppCore:master Jun 8, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.