get g++ to warn on promotions

404 Views Asked by At

Is there a compiler flag that makes g++ warn on promotion? I am aware of g++ compiler flags for warning on conversion (such as -Wconversion, -Wsign-conversion), which makes sense as conversions are potentially quite dangerous, but I do not know of a similar flag for warning on promotion. I know (think?) that promotion should be harmless in general, but still, there may be some cases where I would like to be warned when unexpected promotions arise. I have been googling for that but with no success so far.

1

There are 1 best solutions below

3
On

You can always search in GNU warning options.

-Wdouble-promotion

Give a warning when a value of type float is implicitly promoted to double.