`A2-10-1`: False positive around null identifiers on tuple-like types in structural binding (relevant C++17 only)

Đang mở
#581 0 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ó
4/5
Thời gian dự kiến
3-5 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
Lĩnh vực
devtools

Hướng nghiên cứu

Bắt đầu với phát hiện trong openpilot's dmonitoring.cc:82:10 và kiểm tra IdentifierHiding.ql để xem các binding dạng tuple không có tên được xác định như thế nào. Sau đó xem lại stub tuple.h và biên dịch ví dụ structured binding được cung cấp. Hoàn tất khi ví dụ biên dịch với các phần tử tuple và các binding liên tiếp không còn gây ra false positive.

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

Mô tả

C++17 Difficulty-Low false positive/false negative Impact-Low Standard-AUTOSAR wontfix
Affected rules
  • A2-10-1
  • RULE-5-3
  • M0-1-3
Description

the extractor creates local variables for each identifier, and one for the entire binding. The later is of type tuple without a name, so it gets (null) .
This means if you have another structured binding later on, the rule is falsely triggered because the name is the same.

Example

#include <tuple>
void f9(int x, int y){
  auto tup = std::make_tuple(1, 2);
  const auto & [ a, b ] = tup;
  const auto & [ c, d ] = tup;
}

this example will require additional stubbing to be added to the tuple.h stub, as it currently will not compile due to tuples in that stub not currently having elements. Compilation error message: error: type 'const std::tuple<int, int>' decomposes into 0 elements, but 2 names were provided (ie needs to have mechanism to have elements and get those elements)

another example is the current finding in openpilot- dmonitoring.cc:82:10 from query IdentifierHiding.ql

Ngôn ngữ chính
CodeQL
Star
227
Fork
82
Merge trung bình
6 ngày 7 giờ
Pull request đã merge (30 ngày)
9

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 github/codeql-coding-standards

Tất cả issue của github/codeql-coding-standards

Issue tương tự

Thêm issue về DevTools

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.