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

Compilation error with clang/libc++ and std::equal() on CharacterVectors #854

Closed
lionel- opened this issue May 26, 2018 · 2 comments
Closed

Comments

@lionel-
Copy link
Contributor

lionel- commented May 26, 2018

This pattern recently started to cause CRAN failures in purrrlyr on the fedora/clang machine. I can reproduce it with clang on my macOS machine:

#include <algorithm>
#include <Rcpp.h>

// [[Rcpp::export]]
bool test(Rcpp::CharacterVector x, Rcpp::CharacterVector y) {
  if (x.length() != y.length()) {
    return 0;
  }

  return std::equal(x.begin(), x.end(), y.begin());
}


/*** R
  test("foo", "bar")
*/
In file included from clangCharacterVector.cpp:1:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:682:71: error: use of overloaded operator '==' is ambiguous (with operand types 'const Rcpp::internal::string_proxy<16, PreserveStorage>' and 'const Rcpp::internal::string_proxy<16, PreserveStorage>')
    bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
                                                                  ~~~ ^  ~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:1325:14: note: in instantiation of member function 'std::__1::__equal_to<Rcpp::internal::string_proxy<16, PreserveStorage>, Rcpp::internal::string_proxy<16, PreserveStorage> >::operator()' requested here
        if (!__pred(*__first1, *__first2))
             ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:1337:19: note: in instantiation of function template specialization 'std::__1::equal<Rcpp::internal::Proxy_Iterator<Rcpp::internal::string_proxy<16, PreserveStorage> >, Rcpp::internal::Proxy_Iterator<Rcpp::internal::string_proxy<16, PreserveStorage> >, std::__1::__equal_to<Rcpp::internal::string_proxy<16, PreserveStorage>, Rcpp::internal::string_proxy<16, PreserveStorage> > >' requested here
    return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>());
                  ^
clangCharacterVector.cpp:10:15: note: in instantiation of function template specialization 'std::__1::equal<Rcpp::internal::Proxy_Iterator<Rcpp::internal::string_proxy<16, PreserveStorage> >, Rcpp::internal::Proxy_Iterator<Rcpp::internal::string_proxy<16, PreserveStorage> > >' requested here
  return std::equal(x.begin(), x.end(), y.begin());
              ^
/Users/lionel/R/library/3.5/Rcpp/include/Rcpp/vector/string_proxy.h:204:22: note: candidate function
                bool operator==( SEXP other ) const {
                     ^
/Users/lionel/R/library/3.5/Rcpp/include/Rcpp/String.h:525:17: note: candidate function
    inline bool operator==(const String::StringProxy& lhs, const String& rhs) {
                ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:682:71: note: built-in candidate operator==(struct SEXPREC *, struct SEXPREC *)
    bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;}
                                                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:682:71: note: built-in candidate operator==(const struct SEXPREC *, const struct SEXPREC *)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:682:71: note: built-in candidate operator==(char *, char *)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:682:71: note: built-in candidate operator==(const char *, const char *)
1 error generated.
make: *** [clangCharacterVector.o] Error 1
ccache clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Users/lionel/R/library/3.5/Rcpp/include" -I"/Users/lionel/Dropbox/Projects/R/mock/clangCharacterVector/.metadata" -I"/Users/lionel/Dropbox/Projects/R/mock/clangCharacterVector/.metadata/../inst/include" -I/usr/local/include   -fPIC  -arch x86_64  -ftemplate-depth-256  -Wall  -pedantic  -O0 -g -c clangCharacterVector.cpp -o clangCharacterVector.o
Error in Rcpp::sourceCpp("~/Dropbox/Projects/R/mock/clangCharacterVector/.metadata/clangCharacterVector.cpp") : 
  Error 1 occurred building shared library.
@eddelbuettel
Copy link
Member

Hm. Help would be welcome, maybe between you and @romainfrancois who recently touched / updated StringProxy to add a storage policy. Maybe this is a regression?

@romainfrancois
Copy link
Contributor

Sure. I’ll pick it up.

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

3 participants