Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22040

How to make gcc warn about implicit conversions from floating point to int, but not from double to float

$
0
0

I would like to be warned about implicit conversions from any floating point type to any integer type, but not about the narrowing conversion from double to float. E.g for this code

int main() {    float f = 0.2f;    int i = 1;    double d = 0.3;    i = f;    i = d;    f = i;    f = d;    d = i;    d = f;}

I'd like to get a warning on i = f; and i = d;, but not on any other line.

In clang, this can be achieved via -Wfloat-conversion or -Wconversion -Wno-implicit-float-conversion (the latter one will enable all conversion warnings except that single one I don't want).But in GCC, things are different. -Wfloat-conversionenables all lossy conversions from floating point types at once and I cannot find a flag to further differentiate what it is being converted to. -Wimplicit-float-conversion does not exist.


Viewing all articles
Browse latest Browse all 22040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>