<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55071>55071</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
False positive: deadcode.DeadStores wrongly reports that value stored in variable is not used
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
CiderMan
</td>
</tr>
</table>
<pre>
We have recently upgraded the version of Clang that we use for static analysis and we are getting a false positive reported. I've downloaded v14.0.0 from GitHub and confirmed that it still reports the false positive. A simple example is:
```c
int GetNext(void *, int, int *);
int Foo(void *Pointer)
{
int Handle = -1;
int Instance = 0;
while (((Handle = GetNext(Pointer, Handle, &Instance)) != -1) && (Instance != 0))
{
return 1;
}
return 0;
}
```
This reports:
```
$ /c/Program\ Files/LLVM/bin/clang.exe --analyze test_case.c
test_case.c:8:13: warning: Although the value stored to 'Handle' is used in the enclosing expression, the value is never actually read from 'Handle' [deadcode.DeadStores]
while (((Handle = GetNext(Pointer, Handle, &Instance)) != -1) && (Instance != 0))
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```
However, `Handle` is used to store the return value from one call to `GetNext` so that it can be passed to the next call, so I do not think that the warning is correct. As per the documentation, the warning can be suppressed by adding `(void)Handle;` in the body of the loop but it feels like this warning is not accurate and should not be reported.
Thanks,
Steve.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVU2P2zgM_TXOhRjDdmInOfiQJk1ngHZRoMXucSFLTKwdRTIkOZnZX7-UbOej23NRQ44lkSKf-EimMeK9_guhZWcEixy1V-_Qd0fLBArwLcIZrZNGgznAVjF9pE3m4YLQO4SDseA885ID00y9O-loIoKYWYQjei_pCIMDU6TeGSe9jK46Yz2KFF6SYkkbwly0MtHpOV-kWZrBwZoTfJL-uW-iTW70QdpThEUIpCfPUqnRlotgH92ksAEnT51CwDcWv9Il802S7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