<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112527>112527</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-analyzer-core.UndefinedBinaryOperatorResult false-postive
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nick-potenski
</td>
</tr>
</table>
<pre>
The `clang-analyzer-core.UndefinedBinaryOperatorResult` incorrectly assumes an std::array's size() function can return 0 when used as the condition in a for loop with an index even though the array's size is a compile-time constant. This causes the analysis to skip the loop's body and leads to a false-positive uninitialized variable. I have a simplified reproduction case in Compiler Explorer here: https://godbolt.org/z/jGb3dv1qP
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUksFu3DgMhp9GvhAzsGU7jg8-JLs7iz1tUaQPQEv0mIlGckXJyczTF3ZSBO2tJwMWyY_88KMInz3RoNpH1f5dYE5ziINn83JYQiIvL1yMwV6Hp5lA3ZXGoT8f0KO73igeTIh0_OYtTezJPrLHeP1_oYgpxK8k2SV1VwJ7E2Ikk9wVUCRfSAA9SLKqflD1A8aIV6U7AeEbKX2vdA9T9iZx8GDQQ6SUo4cSXmfykIUsoECaCUzwlvc69oAwhQguhAVeOc0bhL2lN6CVPKQ55PO8d_1KBBZAMOGysKND4ss-VhL6dISnmQUMZqF34H67sEAKIC-87D835D5ucwXoLThCu9cgTOiEDksQTrwSZM-eE6PjG1lYMTKOjo4A_8GMKwGC8GVxPDFZiLTEYPNPE0LbmX-9bxrhn7fFhUgRZoqk6geYU1pkk6pPSp_OwY7BpWOIZ6VPN6VPz_-OtV2r718KO9S2r3ssaKg63Zdd3zVdMQ966rqu0-M4jW03YW0MNk1fTdjqFntNBQ-61E1VVndV1bZNd2yqpqnr8l5Xk2l7a1RT0gXZHZ1bLxu7YJFMQ1XpVneFw5Gc7IHT2tMr7K9K6y1_cdiaDmM-i2pKx5Lkc0zi5Gj44wR--t_0Fzm64TdNnOY8Hk24KH3aaB-fwxLDM5mk9GnfUZQ-fRyxDvpHAAAA__-NDBvh">