<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57902>57902</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Diagnose use of BitInt in format arg checking
</td>
</tr>
<tr>
<th>Labels</th>
<td>
enhancement,
good first issue,
c2x,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
We should diagnose any use of a _BitInt as a `printf`/`scanf` format argument. There are not format specifiers for `_BitInt` yet (they are proposed in https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2858.pdf but that paper missed the deadline for C2x), and these types require special handling due to not undergoing integer promotions (as part of the default argument promotions).
e.g.,
```
_BitInt(32) i = 100;
_BitInt(8) j = 12;
printf("%d %hhd", i, j); // UB for both i and j due to specifier mismatches
printf("%d %hhd", (int)i, (signed char)j); // Ok
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNU02PmzAQ_TVwsRYZEwgcOCQbrdRTL616rIw9gLPGprZpmn_fMSFJu-qhUmIzH8y8efPorLy234D40S5aEqn4YKwHws2VLHjbnnDy_ajCJxMI92gkFZ2dMqHHh4S94ekFN9EivXUTxzQ3LBOYkJEvIzishX9jwz3sZxCqV-B89MR6W_1Y4gqBJKwOI1zX92ZnZ8QjiTJkDGH2SXGIXdnb5XLJ7AzmxQeZWTeg6xxEjpcXjMWEId_d8vCUVni8DKvLOptlT7olkDAinJnP4MikfOyCfYkELrUysKJ7Zb8S1iTsFRlZw8hJuM7giYMfi0KE6zhckxET8LWByAVT7DrxYiS4wUYvMgYDNsKBJhuUNT7OiYzO3IVI8611zxf9ZPCPbESRJfSU0MPthGzIENbmwlXcfqt555PVBRLREEWS4kRySpPi-DGjjgnnWwJ7xLcNM4xihVIi1nIc5Wq9EhWPc-SlOJLbNsjX48pXZ8OI_SJZ5zsTj4VHllEBAln8nzboVxFjozbLq8HgksTIHXo_APj8_k8uUmjzqirqsigLmsq2kE3R8DSooKE93eW-SX3TOWrtKWVsB-IdV5guTrd_a3BQYVy6TNgJDa1_3q8X3NsZBGJ_Q10tEKVX7hvK0rHdlU0HNetYR0GWFRc9rfKi2FXVLpdyn6ead6B9m5RH5AEM6kpAFMODFTZYK0mvnEeosfwzIqJcH4bmZkCs20cdVPwEWFKeUtUyyhhtGMPOLKdZxxrBaQNFB3vKgCc7ChNXOovTxK8rde06WLcMHoNa-eCfQe7X1cAKGuvzJYzWtQfurDlyrSdu0hVpu7LwG06xYqg">