<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64704>64704</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            -Wformat too aggressive on variadic templates with __attribute__((format))
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          zmodem
      </td>
    </tr>
</table>

<pre>
    @apple-fcloutier's 92edd74b37c7a96b1d47dc67cda7f92b65066025 made it possible to put `__attribute__((format))` on variadic templates.

In https://crbug.com/1472532 @pkasting raised an interesting point that because arguments to such templates don't undergo the same promotion that arguments to the regular printf/scanf varargs do, the warning becomes more aggressive:

```
$ cat /tmp/x.cc
template <typename... Args>
void __attribute__((format(printf, 1, 2))) variadic_template_printf(const char* format, Args&&... args) {
  // ...
}

void foo(float f) {
  variadic_template_printf("f: %f", f);
}

$ clang -c /tmp/x.cc -Wno-gcc-compat
/tmp/x.cc:7:37: warning: format specifies type 'double' but the argument has type 'float' [-Wformat]
    7 |   variadic_template_printf("f: %f", f);
      | ~~   ^
      | %f
1 warning generated.
```

Providing a float value for a `%f` conversion with printf is allowed since it will get promoted to double, but that doesn't work with this template function. And there doesn't seem to be any good way of working around the warning!

Perhaps -Wformat needs to be relaxed somehow for this case?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU-Po7gT_TTOpRQE5l84cEinJ9Lv9rvNMSrsArxjbGSbZHoP89lXhtDTPRrNHraF3OBUPb9Xz2Wj92owRC0rX1j5esAljNa1f09W0nTorHxrWZHiPGs69kLbJShyjNceGk5S1kWX16LGpuoyWdRSVLWQWPcN76oyraqUlzChJFABZuu96jRBsDAvAViV3m4YglPdEuh2Y_zE-Km3bsLAeBOfKgVr4I5OoVQCAk2zxkA-YekrS8_b-D8DYwizZ_mZ8SvjV-G6ZUiEnRi_Zk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