<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86476>86476</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Inconsistent warning between gcc and clang about __attribute__ format, misunderstanding?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hstk30-hw
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/7z58WzxxT
```
void __attribute__((format(printf, 1, 0))) f0(const char* format, ...);
void __attribute__((format(printf, 1, 2))) f2(const char* format, ...);
void bar() {
const char* str = "Test";
f0(str, 1); // clang warning, gcc not
f2(str,1 ); // all warning
}
```
>From https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Function-Attributes.html#format
> For functions where the arguments are not available to be checked (such as vprintf), specify the third parameter as zero. In this case the compiler only checks the format string for consistency. For strftime formats, the third parameter is required to be zero.
Clang not incompatible with this ?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVM3OozgQfBpzaQWBDQk5cPjmyyLNfaQ9RsY04B1jZ-0mmeTpVwaSzYzmsFoJOUH9V9VVWIagB4tYs_ILK0-JnGl0vh4DfRfZbrwlrevu9Uh0CUx8MN4w3gyua52h1PmB8ebBeHN4lNWfjx8_vrHsxLKP7dxn27O8Xp3u4HyWRF63M-H5zHjFeNU7P0livLp4baln_BPyeGSMH9cH-ozxSjkbCNQoPeMf8Kz6hDRNY5r48v_G8Lcx_L-PeRvWxtQqNmCHLQoA8HOjQB6YOAHj_BsGYpy_WsXkhWEgv8GKcwBgXTcoI-0AN-mttkPMGJQC6-itnL_Kc3iWb9XSmFftCv1w-q1A69l4N8EveiuVDnbe9HbWaIudU2EN7UTK13-MN81sFWlndx_P_Yd0pMkwLrZVvhtE_AGN89BvRQFuI3oEGhGkH-YJLQWQHiNZkFepjWwNAjloEdSI6jt2EJnPagQZ4PrU9hi3FC6odH9f2tGofQcX6eWEhD4mP9C7FL7aGAugZFgHKzddtEEPzpr7OiQsgRV_FFLbIb4tCutAaNU9XYgE8j3p6ZkbIorfTdcBPP49a4_dRmYB876bz0XzyFvbCEmSjtRvmsYVMBNN0tWiO4qjTLDOD3kuyrLMsmSsj2XbVvmx6w4Cc8V5nvfy0ItS9qLrse0TXfOMF5ngZVaJvMjSYr_Hdo-FrKp938uCFRlOUpvUmOsUhU90CDPW1b447BMjWzRhuTI4X9wZ_VyeEl_H_F07D4EVmdGBwr8dSJPB-qt9rY2evoQW6YZoF2NL222Ol62b6edv-e2DnHSYbYc-kLRdNLdoIJm9-fWy0jTObarcxHgTsWw_u4t3f6EixpuFWnTzwu6fAAAA__-I_pXo">