`const_string_proxy` comparisons are ambiguous with Apple clang (non-const `operator==` / `operator!=`)
還沒有人認領這個 Issue。
評估
研究方向
從 inst/include/Rcpp/vector/const_string_proxy.h 開始,其中四個非 const 的 operator== 和 operator!= 多載與 string_proxy.h 中對應的運算子不同。使用 Apple clang 14 和 17,在 C++17 和 C++20 模式下編譯並執行該 issue 中的 Rcpp::export 範例。完成的標準是 issue 中顯示的所有 const_Proxy 比較都能編譯通過,不出現多載歧義錯誤,並且維持現有的比較行為。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- C++
- 星號
- 796
- 分支
- 217
- 平均合併
- 1 天 12 小時
- 30 天內合併 PR
- 2
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
RcppCore/Rcpp 的其他 Issue
-
難度 4/5 一週以上 新手友好度 15/100
-
難度 4/5 3-5 天 新手友好度 35/100
-
no-issue-activity
難度 5/5 一週以上 新手友好度 25/100
-
Consider masking definition of Rf_error()?可能已有人在做 @Enchufa2 於 396 天前認領。 未關閉
難度 5/5 一週以上 新手友好度 30/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
godotengine/godot#125913 ·
維護者通常 1 天內回覆
-
期待增加虚线线条样式未關閉
難度 2/5 1-3 小時 新手友好度 62/100
-
bug
難度 1/5 1 小時以內 新手友好度 94/100
vllm-project/vllm#70568 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
mw00/project-maya#1368 ·
維護者通常 2 天內回覆
-
needs triage
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆