<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61656>61656</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] readability-magic-numbers cannot handle `long double`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy,
false-positive
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
carlosgalvezp
</td>
</tr>
</table>
<pre>
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
}
```
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVM2uozgTfZpiU0oEJvxkweLmb9Xf5tNIo1m1CrsAzxibsU3uvf30I0i6b7on3dIgZGTsOj5VdY4pBN1b5gaKAxSnhOY4ON9I8saFnsyVv0xJ69R7c36jcTIM-QukJ0i_jmV6f9fp1WmFnXMgauNsj8rNrWEQe8gPj2HaRhxJWxD1snhbqe5b7gDZNv30XWR1enrmbfzEpAJG92t-IHYoDdl-E7V6x40cWP4VID9tQLyAOHomRa02Or5vRuq13Nh5bNmHle1WTtMj-Ct5q20P-QsuZFEHJFzD8BYG-QGls0Er9uh5MiS17VFHfNVxQEJLI6t1SyQbEYrDTxlAcU__eXXw_kBxfp55cfg_T96hs3h046QNezy_TcZ59gu2qIcYp7DUT1xAXHqnWmfi1vkexOULiIv837njjto_QOy3j3X4bdBhSX7yrjU8UtQSXwe26CzjQAHnwH6juNOWFXbGUVzKYHRkTyaAOOLroOWAFNDz37P2rLB9xzgwLoVR5BWOc4g40JWREMr0UV5lukRqO83x1-1fj0Y3safoPIIQIMTnkeNS3-8ki29PdImInuPs7cIqavlZUoiQH1dYyM8g6rfniv3RHLeI_2iLD198o7wAIN4ahr_f5IgDe_5GAJ-r4es0UU2u9vmeEm6ystoXVVWkVTI0mRScla3at13XqoJq4q6oeZeptCPaiUQ3IhV5mos8y7NaVNtMVtxVLddct6Usa9ilPJI2W2Ou4yKjRIcwc1NmZVEmhlo2Yb12hPiw5NqSIwjRkQm8mVzQUV95-V2cEt8sWJt27gPsUqNDDB_oUUez3mMPaMUJf25pSda6RVNWGf63ppLZm-YHT-g4zO1WuhHEZTn4_tlM3v3JMoK4rDkGEJc1zX8CAAD__5BumVo">