[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 --- Comment #7 from South Window --- Since the code generation seems to always reduce a double literal to a floating point in the cases this discussed here, could the function that throws this warning be extended to not throw the warning if all 32 least significant bits of the double literal are zero?
[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 --- Comment #6 from South Window --- Not doing this optimization in -O0 would still leave this warning wrong when optimization is turned on. In my view, the fundamental difference between a generic linter and compiler warnings is that the compiler warning should reflect what the compiler is really doing. If it is not easy to not emit this warning, could it be possible to undo this warning from "elsewhere", or at least to accompany this warning with a withdrawal, e.g. warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion] warning withdrawn: literal '0.5' can be represented without loss of precision as 'float'. Therefore, 'float' precision is used instead of 'double'. [-Wdouble-promotion]
[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2021-07-28 Ever confirmed|0 |1 --- Comment #5 from Richard Biener --- I agree with your reasoning from a QOI perspective. Now, the warning is currently implemented where the language specified promotion happens and the optimization back to float precision happens elsewhere. I suppose we could anticipate this - or at least not do this optimization at -O0.
[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 --- Comment #4 from South Window --- For the user of GCC it doesn't matter whether GCC at compile times converts the literal to a double, and then notices that 32 bits of are zero, and uses a float instead, or if GCC knows right away that 0.5 (and others) don't need to be promoted. Promoting first and then completely undoing the promotion is a purely internal process, effectively a null operation that is of no interest of the user of the compiler. One of the most relevant scopes for -Wdouble-promotion is probably optimization (in particular for SIMD), where the unintended use of a double would cause a significant performance hit. But if the compiler is smart enough and is not using doubles and double instructions, and no precision is changed anywhere in the process, it should be smart enough to not through a this warning.
[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 Andrew Pinski changed: What|Removed |Added Keywords||diagnostic --- Comment #3 from Andrew Pinski --- It is a promotion to double, just happens GCC is able to undo the promotion. Note -Wconversion also avoids warning in similar cases where there is implicit conversion and then the conversion was removed.
[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 --- Comment #2 from make_...@t-online.de --- I don't want to avoid double promotion as double promotion is not actually happening. I want to not be bothered by a false warning :)
[Bug c++/101649] -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #1 from Marek Polacek --- Use 0.5f if you want to avoid promotion to double.