Ambiguous < operation for logical (compiler error)

Đang mở
#263 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp, r
Lĩnh vực
api, tooling

Hướng nghiên cứu

Reproduce the supplied example with the compiler command and inspect cpp11/logicals.hpp, especially how cpp11::r_bool is compared during std::min. Resolve the ambiguity reported between the int and Rboolean operator< candidates; done when the example compiles without that error.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

feature

With the following file

#include <cpp11.hpp>
#include <algorithm>

void c_test(cpp11::logicals t1, cpp11::logicals t2) {
  std::min(t1[0],t2[0]);
}

I get

> cpp11::cpp_source("/home/vspinu/dev/iroll/src/tmp.cpp", quiet = F, clean = F, dir = '/home/vspinu/Dropbox/dev/iroll/')

g++ -std=gnu++11 -I"/home/vspinu/bin/R-4.1.2-bin/include" -DNDEBUG -I'/home/vspinu/.lib/4.1.2/cpp11/include'  -I/usr/local/include   -fpic  -g -O2  -c /home/vspinu/Dropbox/dev/iroll/src/tmp.cpp -o /home/vspinu/Dropbox/dev/iroll/src/tmp.o
In file included from /usr/include/c++/7/algorithm:61:0,
                 from /home/vspinu/.lib/4.1.2/cpp11/include/cpp11/logicals.hpp:3,
                 from /home/vspinu/Dropbox/dev/iroll/src/tmp.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h: In instantiation of ‘const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = cpp11::r_bool]’:
/home/vspinu/Dropbox/dev/iroll/src/tmp.cpp:6:23:   required from here
/usr/include/c++/7/bits/stl_algobase.h:200:15: error: ambiguous overload for ‘operator<’ (operand types are ‘const cpp11::r_bool’ and ‘const cpp11::r_bool’)
       if (__b < __a)
           ~~~~^~~~~
/usr/include/c++/7/bits/stl_algobase.h:200:15: note: candidate: operator<(int, int) <built-in>
/usr/include/c++/7/bits/stl_algobase.h:200:15: note: candidate: operator<(Rboolean, Rboolean) <built-in>
/home/vspinu/bin/R-4.1.2-bin/etc/Makeconf:177: recipe for target '/home/vspinu/Dropbox/dev/iroll/src/tmp.o' failed
make: *** [/home/vspinu/Dropbox/dev/iroll/src/tmp.o] Error 1
In file included from /usr/include/c++/7/algorithm:61:0,
                 from /home/vspinu/.lib/4.1.2/cpp11/include/cpp11/logicals.hpp:3,
                 from /home/vspinu/Dropbox/dev/iroll/src/tmp.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h: In instantiation of ‘const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = cpp11::r_bool]’:
/home/vspinu/Dropbox/dev/iroll/src/tmp.cpp:6:23:   required from here
/usr/include/c++/7/bits/stl_algobase.h:200:15: error: ambiguous overload for ‘operator<’ (operand types are ‘const cpp11::r_bool’ and ‘const cpp11::r_bool’)
       if (__b < __a)
           ~~~~^~~~~
/usr/include/c++/7/bits/stl_algobase.h:200:15: note: candidate: operator<(int, int) <built-in>
/usr/include/c++/7/bits/stl_algobase.h:200:15: note: candidate: operator<(Rboolean, Rboolean) <built-in>
make: *** [/home/vspinu/Dropbox/dev/iroll/src/tmp.o] Error 1
``` R version 4.1.2 (2021-11-01) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS: /home/vspinu/bin/R-4.1.2-bin/lib/libRblas.so
LAPACK: /home/vspinu/bin/R-4.1.2-bin/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=de_DE.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] cpp11_0.4.2

loaded via a namespace (and not attached):
[1] compiler_4.1.2

</details>
Ngôn ngữ chính
C++
Star
224
Fork
52
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của r-lib/cpp11

Tất cả issue của r-lib/cpp11

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.