[clang-tidy] Request: flag unused result of ternary operator with side effects
Open
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
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