Open chrchr-github opened 1 month ago
Looks like this is already coved by -Wdouble-promotion
.
<source>:2:27: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
2 | return a + (float)b + c;
| ~ ^
<source>:2:16: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
2 | return a + (float)b + c;
| ~ ^~~~~~~~
-Wdouble-promotion
warns about the implicit conversion to double
, but not about the nonsensical explicit cast to float
.
The result of the cast is used as
double
, so it is unlikely to be intentional. There should be no warning when the cast affects overload resolution though (if that is even possible).