[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)

Joshua Cranmer via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 20 12:00:15 PST 2023


jcranmer-intel wrote:

> Should this only apply in C23 mode? Standard behavior until C23 is that `_Float16` promotes to `double`. What about C++?

I can't find any reference in older versions of C or TS 18661-3 that suggests that `_Float16` is promoted to `double`. The wording of 6.5.2.2 used to say

> If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type `float` are promoted to `double`. These are called the default argument promotions.

Which suggests that *only* `float` is promoted and that other floating point types are not promoted, and nothing in TS 18661-3 can be construed to suggest promotion either (notably, `_Float32` *doesn't* promote to `double`, even though it's likely the same representation as `float`!).

https://github.com/llvm/llvm-project/pull/74439


More information about the cfe-commits mailing list