`RULE-0-1-1`: Findings should be suppressed for [[maybe_unused]] initialization
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
Locate the implementation and tests for RULE-0-1-1, then trace how initialization assignments involving [[maybe_unused]] are reported. Use the examples in the issue as behavioral cases: suppress the initialization finding, while retaining findings for the later assignments to y and z.
Written by the indexing model from the issue text.
Description
Affected rules
RULE-0-1-1
Description
If the assignment is initializing a variable with the [[maybe_unused]] attribute, we should not report this.
The presence of [[maybe_unused]] disables other rules according to the MISRA spec, and we should follow that principle here as well. If a variable is [[maybe_unused]], that strongly indicates that there's some kind of conditional compilation that uses the variable value, and that the write is ok.
Note that [[maybe_unused]] should not disable all violations of the rule, only ones that would be fixed by adding any read to the variable.
Example
void example_function() {
[[maybe_unused]] int x = 0; // reported, but should not be.
[[maybe_unused]] int y = 1; // should still be reported
y = 2;
[[maybe_unused]] int z = 3;
f(z);
z = 4; // should still be reported.
}
- Dominant language
- CodeQL
- Stars
- 227
- Forks
- 82
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/codeql-coding-standards
-
false positive/false negative Stardard-MISRA-C++
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
github/codeql-coding-standards#1172 ·
-
Difficulty-Low false positive/false negative false-negative Impact-Low Standard-MISRA-C
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty-Medium false positive/false negative false-positive Impact-Medium Standard-CERT-C
Difficulty 4/5 3-5 days Newbie friendliness 48/100
github/codeql-coding-standards#1200 ·
-
`RULE-0-0-1`: "unreachable statement" false positives due to over-pruning of the control-flow graph Openfalse positive/false negative
Difficulty 4/5 3-5 days Newbie friendliness 48/100
github/codeql-coding-standards#1190 ·
-
false positive/false negative Stardard-MISRA-C++
Difficulty 3/5 1-2 days Newbie friendliness 48/100
github/codeql-coding-standards#1165 ·
All issues in github/codeql-coding-standards
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hemilabs/ui-monorepo#2332 ·
-
Help-Wanted Needs-Triage Package-Update
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/winget-pkgs#438662 ·
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
olcf/olcf-test-harness#278 · 1 comment ·