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
Member size() fails for Matrix objects #605
Comments
Complete error (why oh why did you hide those?) from r-base Docker image using Debian testing, and fresh install of Rcpp 0.12.8 off CRAN: > sourceCpp("size.cpp")
size.cpp: In function ‘void test_mat(Rcpp::NumericMatrix)’:
size.cpp:13:18: error: request for member ‘size’ is ambiguous
Rcout << obj.size();
^~~~
In file included from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:165:0,
from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
from size.cpp:1:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/MatrixBase.h:47:25: note: candidates are: R_xlen_t Rcpp::MatrixBase<RTYPE, na, MATRIX>::size() const [with int RTYPE = 14; bool na = true; MATRIX = Rcpp::Matrix<14>; R_xlen_t = long int]
inline R_xlen_t size() const { return static_cast<const MATRIX&>(*this).size() ; }
^~~~
In file included from /usr/local/lib/R/site-library/Rcpp/include/Rcpp/Vector.h:52:0,
from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:40,
from size.cpp:1:
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:274:21: note: R_xlen_t Rcpp::Vector<RTYPE, StoragePolicy>::size() const [with int RTYPE = 14; StoragePolicy = Rcpp::PreserveStorage; R_xlen_t = long int]
inline R_xlen_t size() const {
^~~~
make: *** [size.o] Error 1
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/tmp" -fpic -g -O2 -fdebug-prefix-map=/build/r-base-3.3.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c size.cpp -o size.o
/usr/lib/R/etc/Makeconf:141: recipe for target 'size.o' failed
Error in sourceCpp("size.cpp") :
Error 1 occurred building shared library.
> Thoughts? Why did that bite us before? Matrix has always extended Vector. Weird... |
This SO answer suggests leading the compiler to a preferred version of the ambiguous 'diamond pattern' call via a Anybody have experience with that? Had not seen the trick... |
That worked -- still in the same Docker container of r-base:
Then:
We probably need more of these, but hey, it's a start. |
With the caveat that I'm well out of my depth...
|
I looked at |
@helmingstay I think this is exactly the source of this error. This should be fixed this (maybe other potential problems). |
We all are :) Welcome to the C++ club. @thirdwing Agreed. I should go to bed now; if you can find an alternate clean removing one of the redundant / ambiguous re-definitions -- which won't cause a failure elsewhere -- I'd like that. What I added feels ... like a bandaid. |
Using Debian stretch, g++ 6.2.0-13, R version 3.3.2 (2016-10-31), Rcpp_0.12.8
Tested with NumericMatrix, Integer Matrix, LogicalMatrix
size.cpp:
The text was updated successfully, but these errors were encountered: