`A20-8-5`-`A20-8-6`: Cannot create a smart pointer with `nullptr` value
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start by locating the implementations and tests for rules A20-8-5 and A20-8-6, then reproduce the issue with the unique_ptr and shared_ptr nullptr examples. Determine how the rules classify these initializations; done means nullptr initialization no longer triggers while the stated make_unique and make_shared requirements remain covered by tests.
Written by the indexing model from the issue text.
Description
Affected rules
A20-8-5:cpp/autosar/make-unique-not-used-to-construct-object-owned-by-unique-ptr
Rule A20-8-5 (required, implementation, automated)
std::make_unique shall be used to construct objects owned by
std::unique_ptr.
A20-8-6:cpp/autosar/make-shared-not-used-to-construct-object-owned-by-shared-ptr
Rule A20-8-6 (required, implementation, automated)
std::make_shared shall be used to construct objects owned by
std::shared_ptr.
Description
A20-8-5 triggers when initializing an unique_ptr to nullptr.
A20-8-6 triggers when initializing an shared_ptr to nullptr.
Initializing a smart pointer with a nullptr value can be however necessary in some specific cases.
Example
std::unique_ptr<bool> uniquePtr{nullptr}; // Triggers A20-8-5
std::shared_ptr<bool> sharedPtr{nullptr}; // Triggers A20-8-6
- 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
Difficulty 3/5 1-2 days Newbie friendliness 65/100
github/codeql-coding-standards#1175 ·
All issues in github/codeql-coding-standards
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#156 ·
-
area:workflow bug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fil-donadoni/tolaria#4409 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotenvx/dotenv-vscode#139 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Fission-AI/OpenSpec#1960 ·