`const_string_proxy` comparisons are ambiguous with Apple clang (non-const `operator==` / `operator!=`)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 1/5
- Geschätzter Aufwand
- Unter einer Stunde
- Anfängerfreundlichkeit
- 90/100
Rechercherichtung
Beginne mit inst/include/Rcpp/vector/const_string_proxy.h, wo sich die vier nicht-const operator==- und operator!=-Überladungen von den entsprechenden Operatoren in string_proxy.h unterscheiden. Kompiliere und führe die Rcpp::export-Beispiele des Issues unter Apple clang 14 und 17 in den Modi C++17 und C++20 aus. Erledigt ist, wenn alle im Issue gezeigten const_Proxy-Vergleiche ohne Fehler wegen mehrdeutiger Überladungen kompilieren und das bestehende Vergleichsverhalten erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- C++
- Sterne
- 796
- Forks
- 217
- Ø Merge
- 1 T. 12 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus RcppCore/Rcpp
-
Schwierigkeit 4/5 Über eine Woche Anfängerfreundlichkeit 15/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
-
no-issue-activity
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
-
Consider masking definition of Rf_error()?Evtl. vergeben @Enchufa2 hat das vor 396 Tagen übernommen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
godotengine/godot#125913 ·
Maintainer antworten meist innerhalb von 1 Tag
-
期待增加虚线线条样式Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 94/100
vllm-project/vllm#70568 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
mw00/project-maya#1368 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag