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

NoProtectStorage compile error #849

Closed
romainfrancois opened this issue May 3, 2018 · 2 comments
Closed

NoProtectStorage compile error #849

romainfrancois opened this issue May 3, 2018 · 2 comments

Comments

@romainfrancois
Copy link
Contributor

NoProtectStorage was meant to be used in cases when you don't want to pay for preserve and release because the object is already protected:

> Rcpp::cppFunction( 'void f(){ Rcpp::Vector<STRSXP, NoProtectStorage> s(1); s[0] = "" ; }' )
In file included from file1c206f8abb9c.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp.h:40:
In file included from /Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp/Vector.h:54:
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp/vector/traits.h:73:41: error: no matching constructor for initialization of 'Rcpp::traits::proxy_cache<16, NoProtectStorage>::proxy' (aka 'string_proxy<16>')
                inline proxy ref(R_xlen_t i) { return proxy(*p,i);}
                                                      ^     ~~~~
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp/vector/Vector.h:339:57: note: in instantiation of member function 'Rcpp::traits::proxy_cache<16, NoProtectStorage>::ref' requested here
    inline Proxy operator[]( R_xlen_t i ){ return cache.ref(i) ; }
                                                        ^
file1c206f8abb9c.cpp:6:57: note: in instantiation of member function 'Rcpp::Vector<16, NoProtectStorage>::operator[]' requested here
void f(){ Rcpp::Vector<STRSXP, NoProtectStorage> s(1); s[0] = "" ; }
                                                        ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp/vector/string_proxy.h:43:3: note: candidate constructor not viable: no known conversion from 'Rcpp::traits::proxy_cache<16, NoProtectStorage>::VECTOR' (aka 'Vector<16, NoProtectStorage>') to 'Rcpp::internal::string_proxy<16>::VECTOR &' (aka 'Vector<16> &') for 1st argument
                string_proxy( VECTOR& v, R_xlen_t index_ ) : parent(&v), index(index_){}
                ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp/vector/string_proxy.h:45:3: note: candidate constructor not viable: requires single argument 'other', but 2 arguments were provided
                string_proxy( const string_proxy& other ) :
                ^
/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include/Rcpp/vector/string_proxy.h:35:3: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
                string_proxy() : parent(0), index(-1){};
                ^
1 error generated.
make: *** [file1c206f8abb9c.o] Error 1
clang++  -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/private/var/folders/r_/1b2gjtsd7j92jbbpz4t7ps340000gn/T/Rtmp4GFH1U/sourceCpp-x86_64-apple-darwin15.6.0-0.12.16" -I/usr/local/include   -fPIC  -Wno-unused-result -Wno-c++11-inline-namespace -O3 -c file1c206f8abb9c.cpp -o file1c206f8abb9c.o
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir,  : 
  Error 1 occurred building shared library.
@eddelbuettel
Copy link
Member

eddelbuettel commented May 3, 2018

Hm, still works for, e.g., INTSXP:

R> Rcpp::cppFunction('void f(){ Rcpp::Vector<INTSXP, NoProtectStorage> s(1); s[0] = 1;}')
R> f()
R> 

The string proxies are trickier. Do you consider this fixable? Would you like to work on a fix?

@romainfrancois
Copy link
Contributor Author

Probably just an oversight. I don't suspect many people know about NoProtectStorage. I'll deal with it.

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

No branches or pull requests

2 participants