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

`A20-8-5`-`A20-8-6`: Cannot create a smart pointer with `nullptr` value

Open
#721 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

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

Difficulty-Low false positive/false negative Impact-Low Standard-AUTOSAR user-report
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

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.