<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63524>63524</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-fdiagnostics-show-line-numbers are off in -Wformat warnings
</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>
Consider:
```
$ cat -n /tmp/a.c
1 #include <stdio.h>
2
3 void f(int x) {
4 printf("%f",
5 x);
6 }
$ build/bin/clang -c /tmp/a.c
/tmp/a.c:5:10: warning: format specifies type 'double' but the argument has type 'int' [-Wformat]
5 | printf("%f",
| ~~
| %d
6 | x);
| ^
1 warning generated.
```
The diag location of `a.c:5:10` is correct: it points to the `x` which is the argument in question.
However, the printed line numbers make it look like the `printf` starts on line 5 and the `x` is on line 6, which is not the case.
With `-fno-diagnostics-show-line-numbers` it looks correct:
```
$ build/bin/clang -c /tmp/a.c -fno-diagnostics-show-line-numbers
/tmp/a.c:5:10: warning: format specifies type 'double' but the argument has type 'int' [-Wformat]
printf("%f",
~~
%d
x);
^
1 warning generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVM2SozYQfprm0oULBAj7wMFjh8oDpGrPAjWgjJAcSYx3c9hnTwnbsV0zyUxuUbkEpr_--_qThPdqNEQNVC9QHROxhMm65s_ZSpqTzsofzcEaryQ5KPaQHSG77Ty7_i5_WYm9CJgaBNaG-QSsFZv-YsS4ckRghTK9XiQhFAcfpLKbCYpfHlDs4b1AfLNK4gBsq0zA78B2CPXLA6SM28kpEyIIGANWDevj8ICq8L5iECgeY3CE-vjUGiuxW5SWwNpOGWBtr4UZMe0_6O3pS7GvoNjnGRR7PAtnlBnj62DdLAL6E_VqUOQx_DgRAqulXTpNwGrsloBhIhRuXGYyASdxhykTIgaql_TbJRZUx3sHFUJ9-JyFFXVfP3_-sw1YJe9WvlrfE_fsBNV1jvmtdRzJkBOB5OZjzaz7bxOhVGJEbXsRlDVoBwSePfHJM1Qee-sc9SFSqgKerDLBY7ArccCz7xF2nlQ_RfATm8rgHwv5GH7zmPxXe6Y3csAOK37lkCRqZQjNMnfkPM7ilWI-be0ravVKt3xXxnmGPggXPFpz8axQGPlUlbobeUz2d5XGXubeC09PlX1TYYru6WBsGvkx1gfV-9RP9pzGSOm1wDX-pbxHij45rF8QOH4h9__iDHwu_feCfy_zD66H_6LpRDaF3BU7kVCT821db8tiWydTsxM1q6jclsR4l_Nd1uUiG7pqW-6yLXGZqIZlrMg44zmrdmW94bygvNzVMu_7rBQllBnNQumN1m_zxroxUd4v1PCiYmWiRUfarzc4Y-sgodg_TC2yUR0T10TvtFtGD2WmlQ_-Hi-ooKlJh38dNgpHaIchnqbbEG68-GRxuplCOPmoPdYCa0cVpqXb9HYG1sZU10d6cvb3KFLWrn14YO3ayl8BAAD__x-24XE">