Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`DCL53-CPP`: Reports non syntactically ambiguous object declarations

Open
#812 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
devtools

Research direction

Start with LocalConstructorInitializedObjectHidesIdentifier.ql and its existing test case, then compare the query results for the S1(g1), S1 g2(), S1 g3, S1 g4{}, S1 g5(1), and S1 g6{1} examples. The work is done when the DCL53-CPP query reports the non-compliant declarations without the listed false positives, or the remaining parsing limitation is documented.

Written by the indexing model from the issue text.

Description

Difficulty-Medium false positive/false negative Impact-Low
Affected rules
  • DCL53-CPP
Description

LocalConstructorInitializedObjectHidesIdentifier.ql currently identifies variable declarations that call a constructor and hide an outer scope variable. However, this does not fully capture the cases covered by this vexing parsing situation, which is looking for S1(g1).

The following additions to the query could help address this problem:

  v.getInitializer().getExpr().(ConstructorCall).getNumberOfArguments() = 0 and
  not v.getInitializer().isBraced()

However this would still flag S1 g3; below - as we don't currently have a record of where the brackets were during parsing.

Example

This modification of the test case highlights the problems:

int g1 = 0;
int g2 = 0;
int g3 = 0;
int g4 = 0;
int g5 = 0;
int g6 = 0;
void f1() {
  S1(g1);   // NON_COMPLIANT
  S1 g2();  // NON_COMPLIANT
  S1 g3;    // COMPLIANT[FALSE_POSITIVE]
  S1 g4{};  // COMPLIANT[FALSE_POSITIVE]
  S1 g5(1); // COMPLIANT[FALSE_POSITIVE]
  S1 g6{1}; // COMPLIANT[FALSE_POSITIVE]
}
Dominant language
CodeQL
Stars
227
Forks
82
Avg merge
6d 7h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/codeql-coding-standards

All issues in github/codeql-coding-standards

Similar issues

More DevTools issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.