https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101649
Bug ID: 101649 Summary: -Wdouble-promotion warning emitted when floating point literals are not actually promoted to doubles Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: make_...@t-online.de Target Milestone: --- GCC emits a double promotion warning when using the literal 0.5 with a float. For example float func(float num) { return num * 0.5; } warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion] 3 | return num * 0.5; However, GCC does not actually use the double representation for this literal (and others than can be represented equally in float as in double). The assembler output for both "0.5" and "0.5f" is the same: func(float): push rbp mov rbp, rsp movss DWORD PTR [rbp-4], xmm0 movss xmm1, DWORD PTR [rbp-4] movss xmm0, DWORD PTR .LC0[rip] mulss xmm0, xmm1 pop rbp ret .LC0: .long 1056964608 This warning is misleading and should not be emitted