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

Aberta
#581 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
cpp
Domínio
devtools

Direção de pesquisa

Comece pela descoberta em openpilot's dmonitoring.cc:82:10 e inspecione IdentifierHiding.ql para ver como bindings semelhantes a tuplas sem nome são identificados. Em seguida, revise o stub tuple.h e compile o exemplo fornecido de structured bindings. Está concluído quando o exemplo compilar com elementos de tupla e bindings sucessivos não causarem mais um falso positivo.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
CodeQL
Estrelas
227
Forks
82
Merge médio
6d 7h
PRs com merge (30d)
9

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de github/codeql-coding-standards

Todas as issues de github/codeql-coding-standards

Issues semelhantes

Mais issues de DevTools

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.