llvm / llvm/llvm-project

[clang-tidy] Request: flag unused result of ternary operator with side effects

Open
#222,335 3 comments 0 reactions 0 assignees View on GitHub
check-request clang-tidy
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
#include

int main(int argc, char* argv[]) {
argc ? std::cout << "true" : std::cout << "false";
}
```
https://godbolt.org/z/qq4j1zbob

Somewhat related: https://github.com/llvm/llvm-project/issues/34348

Contributor guide

Open the contributing guide

Research direction

Start with the C++ reproducer in the issue and the linked Compiler Explorer example, then inspect existing clang-tidy checks for unused expression results and the related issue #34348. Done means clang-tidy reports the unused ternary result when its branches have side effects, with coverage for the shown case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.