-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
This piece of code produces an incorrect warning when compiled with -Wformat:
template <typename... Args>
__attribute__((__format__(__printf__, 1, 2)))
void my_format(char const *format, Args... args);
void foo()
{
float x = 0.f;
my_format("%f", x);
}<source>:9:18: warning: format specifies type 'double' but the argument has type 'float' [-Wformat]
my_format("%f", x);
~~ ^
%fMeanwhile, declaring my_format as a variadic function results in no warning, as expected:
__attribute__((__format__(__printf__, 1, 2)))
void my_format(char const *format, ...);
void foo()
{
float x = 0.f;
my_format("%f", x);
}It doesn't seem to be related to my_format being templated, declaring it as void my_format(char const *format, float f); results in the same incorrect warning.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer