<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54802>54802</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-14: diagnostics: wrong source range in output with -fdiagnostics-print-source-range-info
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bfrg
</td>
</tr>
</table>
<pre>
Run: `clang -fdiagnostics-print-source-range-info test.c`
```c
int scanf(const char* format, ...)
{
return 0;
}
int main()
{
int aaaa = 1;
scanf("%d", aaaa);
}
```
Result (with clang 14.0.0):
```
test.c:9:17:{9:17-9:21}{9:12-9:23}: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat]
scanf("%d", aaaa);
~~ ^~~~
1 warning generated.
```
The locations inside the braces seem to be wrong. These suggest the following:
```
int main()
{
int aaaa = 1;
scanf("%d", aaaa);
^ 9:17 caret
~~~~~ 9:17-9:21 range before caret
~~~~~~~~~~~~ 9:12-9:23 range after caret
}
```
If we assume that the squiggles in the output are correct, the ranges should be specified like:
```
test.c:9:17:{9:12-9:13}{9:18-9:20}: warning: format specifies type 'int *' but the argument has type 'int' [-Wformat]
scanf("%d", aaaa);
~~ ^~~~
1 warning generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlVU2P2yAQ_TXkgmxhbNfJwYdkP6ReV5V6xnhs0xKTAm60_74Dtrve7e5qe-ipCMUDM7wZ3syQxrSP9cM0kvxIyScmtRh7mnStEv1onFfSJRerRp84M1kJiUU9JGrsDPXgfCrxEGG3hB2XX1zGKec1HqVOirEjfC_N6DyVg7CEH2ln7Fl4wm9omqaEH5bz1WkWKA4LfrIjZSQ_rdrbrbMAfhZqROzXAYKBwEFJfkuz3zBBtQZFOCe8bOPnJhoHqD8drvfa-n8AN2lPEeWq_EBn8rIiZSmLIC85mZcLb_kxWGRVMKtOs5yED8-C12WLz1t52MIUXYUd1dgHceaPugtI1Slw1D9eAGOpwqWRYJRoM3nqB6DC9tMZcH8Qz-yCDSlPydclGeXtE0EfZIhuBqnucAahvJvlMKNZtoZOexjBCg9t-g6zXzBobaTwCmsG0-hUC_EmjRUS7-oAztQb2gC9WjP2KcUTDqib-h7pjaad0dpcZ7ZedfXvy4e-GMjLZjXnnEqBdf6GfXW3nc_OLbVCY0ciEZhCeAPrBcyr8wl5LbkFWXQe7Bb4_Z743NErHnIOCw7TIOZcuB-T6nsNIZdxw0z-gsUpQszGWpDxJQia6BUzPJhJtyHBa4W3VKvv8PddNd8nyzddtZ-vyP6Drtq1dd4e8oPYeeU11DfhkUqyIlx288pHGkIn0fmhX5KP2VoyFV-4D_0x7Car68H7SwAl_B5nj4enJpXmjAutf64fhDDfYu7vFVYMOBTKYs_4bqizfVmxSlSsgUPZ5KxqioxnvJBwKPY5yJ0WDWhXI9PI8E7VnHHOClbhT1WylLdlnu8bmXXZPj-wihQMsNt1GhynxvY7W8cYmql3qNTKefekxApW_Qiw4ovJD8bWTYe6GGsdA_0FKnoBQw">