`A0-1-1`: initialization of constexpr used as NTTP is detected as useless assignment

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

@lcartey đang làm issue này rồi.

Từ ngày 17/1/2025.

  • #732 của @fjatWbyT — đã merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Difficulty-Medium false positive/false negative Impact-Medium Standard-AUTOSAR user-report
Affected rules
  • A0-1-1 (useless assignment)
Description

Constant expression used as non-type template parameter (NTTP) produces useless-assignment false positive. It can be reproduced with integer NTTP.

Example
#include <ratio>

int main() {
  constexpr int one      = 1;     // True positive, this one is indeed unused (therefore, assignment is useless).
  constexpr int thirteen = 13;    // False positive, used in the second argument:
                                  // it can be verified that main returns 13.
  std::ratio<1, thirteen> ratio;
  return ratio.den;
}

Both definitions of one and thirteen are alerted as unused on query cpp/autosar/src/rules/A0-1-1/UselessAssignment.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

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.