`const_string_proxy` comparisons are ambiguous with Apple clang (non-const `operator==` / `operator!=`)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 90/100
Direzione di ricerca
Inizia da inst/include/Rcpp/vector/const_string_proxy.h, dove i quattro overload non const di operator== e operator!= differiscono dagli operatori corrispondenti di string_proxy.h. Compila ed esegui gli esempi Rcpp::export dell'issue con Apple clang 14 e 17 nelle modalità C++17 e C++20. Il lavoro è completo quando tutti i confronti di const_Proxy mostrati nell'issue compilano senza errori di overload ambiguo, preservando il comportamento di confronto esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Comparing two CharacterVector::const_Proxy values does not compile with Apple clang 14 in C++20 mode, and
comparing a const_Proxy with a SEXP does not compile with Apple clang 14 or 17.
#include <Rcpp.h>
// [[Rcpp::export]]
bool same(const Rcpp::CharacterVector x) {
Rcpp::CharacterVector::const_Proxy a = x[0], b = x[1];
return a == b; // ambiguous: clang 14, C++20
}
// [[Rcpp::export]]
bool sx(const Rcpp::CharacterVector x, SEXP s) {
Rcpp::CharacterVector::const_Proxy a = x[0];
return a == s || a != s; // ambiguous: clang 14 and 17, C++17 and C++20
}
error: use of overloaded operator '==' is ambiguous (with operand types
'Rcpp::CharacterVector::const_Proxy' (aka 'const_string_proxy<16, Rcpp::PreserveStorage>') and
'Rcpp::CharacterVector::const_Proxy')
In inst/include/Rcpp/vector/const_string_proxy.h the const char* and const const_string_proxy&
overloads of operator== and operator!= are not declared const, while the SEXP overloads and all the corresponding operators in string_proxy.h, are.
Adding const to those four operators resolves all of the above (also in PR):
@@ -97,17 +97,17 @@ namespace internal{
inline bool empty() const { return *begin() == '\0' ; }
inline reference operator[]( R_xlen_t n ){ return *( begin() + n ) ; }
- bool operator==( const char* other){
+ bool operator==( const char* other) const {
return strcmp( begin(), other ) == 0 ;
}
- bool operator!=( const char* other){
+ bool operator!=( const char* other) const {
return strcmp( begin(), other ) != 0 ;
}
- bool operator==( const const_string_proxy& other){
+ bool operator==( const const_string_proxy& other) const {
return strcmp( begin(), other.begin() ) == 0 ;
}
- bool operator!=( const const_string_proxy& other){
+ bool operator!=( const const_string_proxy& other) const {
return strcmp( begin(), other.begin() ) != 0 ;
}
Affected CRAN packages that fail to install for this reason: comparator, IFC, IsoSpecR,
packcircles, runner.
Seen with R 4.6.1, Rcpp 1.1.2, Apple clang 14.0.3. The operators are unchanged in current Rcpp master (279801e, 1.1.2.8), where Apple clang 17.0.0 (arm64) gives the same SEXP errors but accepts same(). With the changes above the example compiles in both modes with both compilers.
- Lingua principale
- C++
- Stelle
- 796
- Fork
- 217
- Merge medio
- 1g 12h
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RcppCore/Rcpp
-
Difficoltà 4/5 Più di una settimana Idoneità per principianti 15/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
no-issue-activity
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Consider masking definition of Rf_error()?Forse già presa @Enchufa2 l’ha presa 396 giorni fa. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
Tutte le issue di RcppCore/Rcpp
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
godotengine/godot#125913 ·
I maintainer di solito rispondono entro 1 giorno
-
期待增加虚线线条样式Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
vllm-project/vllm#70568 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
mw00/project-maya#1368 ·
I maintainer di solito rispondono entro 2 giorni
-
needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno