<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/80548>80548</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Unexpected -Wconstant-logical-operand warning when compiled with c2x/gnu2x
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fel1x-developer
</td>
</tr>
</table>
<pre>
```
#include <stdio.h>
int main() {
if ((64 > 32) && (32 < 64))
printf("%lu\n", sizeof(int));
return 0;
}
```
```
$ clang -std=c2x main.c
main.c:4:36: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
4 | if ((sizeof(int) > sizeof(short)) && (sizeof(int) < sizeof(long)))
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:4:36: note: use '&' for a bitwise operation
4 | if ((sizeof(int) > sizeof(short)) && (sizeof(int) < sizeof(long)))
| ^~
| &
main.c:4:36: note: remove constant to silence this warning
4 | if ((sizeof(int) > sizeof(short)) && (sizeof(int) < sizeof(long)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```
Build with `-std=c17` or `-std=gnu17` and below prints no error, but this emits warnings when built with `c2x` or `gnu2x`. Is this expected behaviour that reflects some changes in C23 or a bug?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMlMmOMycQx5-m-lKyhaEX96EPXsZSHiDKuZfqbiIMFst4ksP37BG92NZ8mckt-hCy6SqK4v8roHZODpqoguwI2Tmpgx-NrXpSu49NR--kzI1s0pjurwpytnR2BnYALqRuVegIQZyc76TZjiDeFu_0K7XHay018D3wEqE4rt5S9jhZ93mKIN5Q8GkGz4Hn0SN4XBbzFHgZ-xoHrLxZqX0_RXPgmQqQnfQ0PqGTf5OJPqn9EimOr1sCVlrywWpkT09xXgafJP6rkafYqloPuHG-A3Fu-cckctvOE5axOKQgDiIHccB7bbXUQxwGR2h6VGaQba0QeDFrBl7gXfoRW6Odr7XHSL7WHUJ23PyxWjdL4GbxQrZsHRExRShOuLYH4U9MJtwPmxuNXUi90P855AWtMnpY2K6FmTPG7JC9If74pn0JSRtPK6EVS4G9sVhjI_1dRnJRtZdG_3Kif_xk4_l_SrV0Ne_0LLk36KQi3RL6UbrHufkk9n8Vuer7ts1zd-uGcSAdC0Xd9puLdQxSdfOhh5ytt2lXQM7Q2BfboMNsjdehIWXuOL0BDrVBstbYePWb4GdqdJX-wc7hfSSNTZDKP3K1_OOZZNBh-tzib25Z4ONGraeYa6zfpQkW_Vh7tNQrar1DZ66E7VjrgRxKjScucD6nYQBxeRWZdJXoSlHWCVW7guVlkadsl4zVnucsbUXHi77pc5F21PS83DdZ2ee8a_tEVpzxlHEmdjnLU7Ylse_6escynqYFEwQpo2st1Vap9-vW2CGRzgWq9ixL94mqG1Juetg513THyRmfyeyc2CrGbJowOEiZks675ypeekXV7_qB4evn51HwCXJrrjepaKlphMwvE90kWFWN3t8ciAPwS7RLP4Zm25or8EtMvfxtbtb8Sa0Hfpk27IBfJkH_BAAA__9fKPWt">