Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing _Float16 to printf where double is expected should raise a warning #68538

Closed
sh1boot opened this issue Oct 8, 2023 · 1 comment · Fixed by #74439
Closed

passing _Float16 to printf where double is expected should raise a warning #68538

sh1boot opened this issue Oct 8, 2023 · 1 comment · Fixed by #74439
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Comments

@sh1boot
Copy link

sh1boot commented Oct 8, 2023

Unlike __fp16, _Float16 is passed without conversion to double, and so it's an unexpected argument type at that position when used with %f and the like, and should raise a warning.

https://godbolt.org/z/r5o7djxbd

@EugeneZelenko EugeneZelenko added clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer and removed new issue labels Oct 9, 2023
@sh1boot
Copy link
Author

sh1boot commented Oct 13, 2023

Demonstration showing how GCC gives the warning and Clang does not:
https://godbolt.org/z/b6dq9Mjae

Luhaocong added a commit that referenced this issue Jan 8, 2024
According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf,
default argument promotions for _FloatN types has been removed.

A warning is needed to notice user to promote _Float16 to double
explicitly, and then pass it to format specifier '%f', which is
consistent with GCC.

Fixes: #68538
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this issue Jan 28, 2024
According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf,
default argument promotions for _FloatN types has been removed.

A warning is needed to notice user to promote _Float16 to double
explicitly, and then pass it to format specifier '%f', which is
consistent with GCC.

Fixes: llvm#68538
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:diagnostics New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants