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

`A5-16-1`: Constructing `std::string` is considered as sub-expression in ternary operation

Open
#754 2 comments 0 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
tooling

Research direction

Start with the implementation of the cpp/autosar/ternary-conditional-operator-used-as-sub-expression rule and reproduce the reported std::string, Test, and std::uint32_t examples. Done means the string initialization no longer produces a false positive while genuine ternary sub-expressions remain diagnosed.

Written by the indexing model from the issue text.

Description

Difficulty-Low false positive/false negative Impact-Medium Standard-AUTOSAR user-report
Affected rules
  • A5-16-1: cpp/autosar/ternary-conditional-operator-used-as-sub-expression

Rule A5-16-1 (required, implementation, automated)
The ternary conditional operator shall not be used as a sub-expression.

Description

When initializing a string inside a ternary expression, A5-16-1 error is triggered.
I tried with std::uint32_t and with a class, and the error was not triggered.

Example
std::string const str{cond ? "str1" : "str2"}; // Triggers A5-16-1

Test const test{cond ? Test() : Test()}; // Ok
std::uint32_t const nb{cond ? 0 : 1}; // Ok
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.