[clang-tidy][false-positive] `modernize-use-nullptr` suggests comparing `std::strong_ordering` with `nullptr`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`std::strong_ordering::operator==` is only defined for literal zero `0`. However, `modernize-use-nullptr` suggests to replace `0` with `nullptr`.
https://godbolt.org/z/ME9Gs3Pb5
```
:4:41: warning: use nullptr [modernize-use-nullptr]
4 | void(std::strong_ordering::equal == 0);
| ^
| nullptr
:5:46: warning: use nullptr [modernize-use-nullptr]
5 | void(std::strong_ordering::equivalent == 0);
| ^
| nullptr
:6:40: warning: use nullptr [modernize-use-nullptr]
6 | void(std::strong_ordering::less == 0);
| ^
| nullptr
:7:43: warning: use nullptr [modernize-use-nullptr]
7 | void(std::strong_ordering::greater == 0);
| ^
| nullptr
4 warnings generated.
```
Current trunk: 5e47ef456a7860e1fa12428f96ff072ff6c4f905
Possibly related to #53961.
Contributor guide
Research direction
Start with the modernize-use-nullptr clang-tidy check and reproduce the diagnostic using the linked Compiler Explorer example. Trace how comparisons against literal 0 are identified, then verify that comparisons involving std::strong_ordering no longer produce the nullptr suggestion while ordinary null-pointer replacements still do. The issue names no source file or test, so locate the check's existing tests before making the change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100