| Issue |
61656
|
| Summary |
[clang-tidy] readability-magic-numbers cannot handle `long double`
|
| Labels |
clang-tidy,
false-positive
|
| Assignees |
|
| Reporter |
carlosgalvezp
|
Example:
```
void foo(long double);
int main()
{
foo(1.0L);
}
```
Leads to:
```
$ clang-tidy -checks=-*,readability-magic-numbers main.cpp
warning: 1.0L is a magic number; consider replacing it with a named constant [readability-magic-numbers]
foo(1.0L);
^
```
[Repro on Compiler Explorer](https://godbolt.org/z/cMEfefabY).
This is problematic when one has user-defined floating literals, which as required by the standard must have a `long double` as input:
```
float operator ""_meters(long double x)
{
return static_cast<float>(x);
}
void foo(float);
int main()
{
foo(1.0_meters); // Warning here
}
```
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs