<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60525>60525</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: Wtautological-unsigned-zero-compare fires in cases where comparision operand is known to be non-zero
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ADKaster
</td>
</tr>
</table>
<pre>
In the following example:
```c++
static constexpr unsigned c = 0;
int main()
{
if constexpr (c > 0) {
for (unsigned i = 0U; i < c; ++i) {}
}
return 0;
}
```
The for loop will never be executed or even compiled into the final binary if `c` is `0`. Nevertheless, `clang++ -Wtautological-unsigned-zero-compare` fires on that line:
```
<source>:7:33: warning: result of comparison of unsigned expression < 0 is always false [-Wtautological-unsigned-zero-compare]
for (unsigned i = 0U; i < c; ++i) {}
~ ^ ~
```
Godbolt link: https://godbolt.org/z/av6x66d9b
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVEFv6jgQ_jWTywhk7CSEQw5Qymq10p52tWcnmQRvjY1sB2gP_e1PdoDSJ_Wp0osiGDPDN_N93yTSezUYohqKDRTbTI5hb1293v4lfSCXNbZ7rf80GPaEvdXanpUZkC7ycNQEYg1sC-z2WbLpboFv4p1-9UEG1WJrjQ90OTocTWrZYYsgtshAbB5RlAl4kMoAr4CvrpnltQQRUfUPYMCrCPOMDPgKP9XFq7ep5N5STS3_BbFJ8RO2MZzmVTeI5fYD5dPBURideRz5lr1zf6TyTxLNobb2iGelNRo6kcOGkC7UjoE6tA7pRAZbezgqHUc0wU5yKyM1NspI9xpJJ2FLhsrHMPaa498RL-xJk_fAn1KNlmaYCOHsvyDHYLUdVCv17CbD7I2cncWO0lGE7JUjjzbaLANqZb609noUT96OriUQzyDWSxBrIUCs8SydUWaIoSM_6oC2x6mR8tbE092L6B95r6xJRiRiUp_lq8deak8IxeZbBIqbQ7_v9tfXO0LxjO-_cPsP2zVWJ_leogD7EI4-6sh3wHfDlJ1bNwDfvQHfyVN5Kctu1WRdLbqVWMmM6kW5LArGeMWyfc1kwXjeL_pF1eVUsEo0tKjavCjFgsmKMlVzxgXjLGdVnudsXgrWVB3lJVt0tCwqyBkdpNJzrU-H2DtT3o9Ul6zgRaZlQ9qnR59zQ2dMSeA8vglcHf8za8bBQ8608sF_oAQVNNXTqok1fsOl644pg6305PG8J0f31YhLYI_kpOniGrwYezYYbHxSjDUJKBudrn_SVIX92MxbewC-i7Ndv2ZHZ_-nNgDfJUYe-C4x_hEAAP__7kp4dQ">