Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
knewbury01 opened this issue May 7, 2024 · 0 comments
Labels
C++17 false positive/false negative An issue related to observed false positives or false negatives. wontfix This will not be worked on

Comments

@knewbury01
Copy link
Contributor

knewbury01 commented May 7, 2024

Affected rules

  • A2-10-1
  • RULE-5-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

@knewbury01 knewbury01 added the false positive/false negative An issue related to observed false positives or false negatives. label May 7, 2024
@rvermeulen rvermeulen added C++17 wontfix This will not be worked on labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++17 false positive/false negative An issue related to observed false positives or false negatives. wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants