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

R dies on scalar/vector mismatch #375

johnlaing opened this issue Sep 21, 2015 · 1 comment


Copy link

commented Sep 21, 2015

If I declare a function taking a scalar and call it with a vector, R dies. Ideally Rcpp would check the length of the input and throw.

I understand this is likely a non-trivial fix. Nevertheless...

#include <Rcpp.h>
// [[Rcpp::export]]

std::string ex(std::string x) {
  std::string y = x;

ex("foo") ## it works if I pass it a scalar
# [1] "foo"

ex(c("foo", "bar")) ## but explodes on a vector
# *** Error in `/usr/lib/R/bin/exec/R': free(): invalid pointer: 0x0000000002d15418 ***
# Aborted

This comment has been minimized.

Copy link

commented Sep 22, 2015

Thanks, @eddelbuettel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.