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

Closed
johnlaing opened this issue Sep 21, 2015 · 1 comment
Closed

R dies on scalar/vector mismatch #375

johnlaing opened this issue Sep 21, 2015 · 1 comment

Comments

@johnlaing
Copy link

@johnlaing johnlaing 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...

Rcpp::sourceCpp(code='
#include <Rcpp.h>
// [[Rcpp::export]]

std::string ex(std::string x) {
  std::string y = x;
  return(y);
}
')

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
@johnlaing
Copy link
Author

@johnlaing johnlaing commented Sep 22, 2015

Thanks, @eddelbuettel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.