<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56583>56583</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Invalid format-security warning with empty argpack
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
msharov
</td>
</tr>
</table>
<pre>
```c++
#include <stdio.h>
template <typename... Args>
void print_error (const char* fmt, Args... args)
{
printf (fmt, args...);
}
int main (void)
{
print_error ("message\n");
return 0;
}
```
Produces incorrect `-Wformat-security` error, even though `fmt` is the string literal `"message\n"`:
```
tes.cc:6:13: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
printf (fmt, args...);
^~~
tes.cc:11:5: note: in instantiation of function template specialization 'print_error<>' requested here
print_error ("message\n");
^
tes.cc:6:13: note: treat the string as an argument to avoid this
printf (fmt, args...);
^
"%s",
1 warning generated.
```
No warning is emitted when print_error is given additional arguments.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVM-zkzAQ_mvCJfMYCKWUA4e-Vme8ON48OmlYIAoJJks79a93k77Wap_OqEwISfbXt98uOdj23LB1dhmKiecwsj3LtkwU2qhxaYGzYuex1TYdWPHmRRpnhGkeJUYNPM9g5ARpmvKt6_1N9Wh1y2enDX4C56zjTGyUNR65GqRjYsu7CZnYRatgLYO1qF8CVS94OD3RSxccvJjIi0nQLq64q_09RDLgk9QmGAUkf3D8Ax4TYgLvZQ-s3Bna3QcI-g5wcYZnr0S9knnZfnC2XRR4Tlxa50AhJ9nTx866SeKTB7U4jWc64zF6SAqOYDgOdumHoBxSJbH2dAbcI0Ht-agRnByD_BEsnRXbV-Eg-FQpkq7pzQua-Ek6Qx7D8gLqGoICGotcPoQUm9kiGNRyHM-UWEwCiCLOyufH1Mr93xWQ3z2sfMOqOH6Gn-c0lQEzQYTwpQoTEpQBFmpruO14txgV17c-9TMogq2_XXSYqO4qT00cmlZUVN6vC3iElg9Amf1zmwT4v-P9ChwdEOd3pZWeSxOIWSYimaPlMv5COGj_f0w-HgbIpY-fHb_I82tH8B4MFZxYSF_tpff2pkmtApPGQNhpoOa954lkvQ4dLdtWB9apha7J-TRpm6Kti1omqHGE5p05Unla_ksT3SKdNA4Ua6YjcjJL9SVZ3NgMiLMPTS_e0uhJaTmkyk60Gcfj9fM0O_uZfkHaau-pwrQo1-WmSIYmh2pVb2qVZ1LlqxpqtZHdWtVdWW2yHIpklAcYfUMtTnQZOPHoIlBX7hPdiEyIrMorkdGiTkFAuT4Aea1r6ETGVhnQNTSmAUdqXZ-4JkI6LHTZrbJRe2LjJpTe694AxHDkXy50H7hm8nRj2mMSQzcR-ne3Rrs3">