`const_string_proxy` comparisons are ambiguous with Apple clang (non-const `operator==` / `operator!=`)
まだ誰も着手していません。
評価
調査の方向性
inst/include/Rcpp/vector/const_string_proxy.h から始めます。ここでは、4 つの非 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時間
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RcppCore/Rcpp のほかの issue
-
難易度 4/5 1週間以上 初心者へのやさしさ 15/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
no-issue-activity
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
-
Consider masking definition of Rf_error()?対応中かも @Enchufa2 が 396 日前に担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 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 日以内に返信