[Clang] `-Wliteral-conversion` only warns for conversion from floating-point literals
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
From the [documentation](https://clang.llvm.org/docs/DiagnosticsReference.html#wliteral-conversion), one may expect that the warning also covers non-floating-point literals. But currently the warning is restricted to conversion from floating-point literals.
Example ([Godbolt link](https://godbolt.org/z/fTr49cK9x)):
```C++
void test() {
(void)('*' || true); // no warning
(void)(u8'*' || true); // no warning
(void)(u'*' || true); // no warning
(void)(U'*' || true); // no warning
(void)(L'*' || true); // no warning
(void)("" || true); // no warning
(void)(u8"" || true); // no warning
(void)(u"" || true); // no warning
(void)(U"" || true); // no warning
(void)(L"" || true); // no warning
(void)(42 || true); // no warning
(void)(42U || true); // no warning
(void)(42L || true); // no warning
(void)(42UL || true); // no warning
(void)(42LL || true); // no warning
(void)(42UL || true); // no warning
(void)(42.0F16 || true); // warning
(void)(42.0F || true); // warning
(void)(42.0 || true); // warning
(void)(42.0L || true); // warning
}
```
This seems to be by design.
https://github.com/llvm/llvm-project/blob/9dffcd2752af16a09eeb4131f90a1a0fe2b76a1f/clang/include/clang/Basic/DiagnosticSemaKinds.td#L4598-L4603
Do we want to extend the coverage of `-Wliteral-conversion` or clarify that it's restricted to FP literals?
Contributor guide
Research direction
Start with the -Wliteral-conversion definition in clang/include/clang/Basic/DiagnosticSemaKinds.td and compare it with the corresponding DiagnosticsReference documentation. Reproduce the Godbolt example to confirm the current behavior, then determine whether non-floating-point literals should be covered or the documentation should state the restriction. Done means the chosen behavior and its documentation are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100