<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/83746>83746</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang++] Compiler producing wrong code/discarding code.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Rugau
      </td>
    </tr>
</table>

<pre>
    I accidentally found this bug that seems to be present in clang++ >= 13.0.0
```
#include <stdio.h>

int main(int argc, char** argv)
{
    if (argc * 2 > 999)
      printf("WTF?"); 

    while(1);
}
```

```
main:                                   # @main
        push    rax
        lea     rdi, [rip + .L.str]
        xor     eax, eax
        call    printf@PLT
.L.str:
        .asciz  "WTF?"
```

The compiler removed the if condition above, and considered it to be always true.

This is only present in the C++ compiler, in the C compiler it is producing the correct code.

In GCC and MSVC compilers, this does not happen and produces the correct code.

Is this right?
(and by the way, where is while(1)? -- the compiler removed it too? ðŸ¤£ )

https://godbolt.org/z/5MWEKrKjz

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVE2P4ygQ_TWVS6ktAnEnPviQj_FqNDPSane0c8ZQsRkRsAB3Ov3rVzjuTdKa3bUi40C9V49HUTJG0zmiGsodlIeFHFPvQ_3H2Mlx0Xp9qT-jVMpocklae8GjH53G1JuI7dhh6mXCSHSKmDy2hEOgSC6hcaisdB3wHfAdgvgE4oBLUbCCATsA28Izm3_Xv1wYp-yoCUHsY9LGF32GXVent3EJT9I44Jv8KUOngO9R9TIA3wLf5qkX4NUMWu-uH4iI5ojANxmCOZBnSVhV1T_ROD1DMC4dgW-A8x_fGxANcJ5jxA7vpeTYc28sAd8sr-vvSQ-_3t-vJqfNiDn1fz7ABcKKTYA7uYjDGPs8Bvn6uGBJTmPQJpsE5S6YAfNhFF-LmAKUh0fAqw_TSPI1A-gjoZLW3lm0Yr9__X6NmAnF9hFQyKjMW9Z-Z-W_e_O9J1T-NBhLAQOd_AvlSqN8dMo7bZLxDmXrXyjrk07n6Wg0BdJo0lyB0p7lJWIKIxWP9CaiieidvdyXac6wn8v0PX3mf1-6aTIp44fg9aiM66Zl5UMglVB5_Zjus8Pf9leV3_7868YSM_d0f7SniM4n7OUwkJtCr-QU_4c7XhmC6fqUfZ1v0CZTtJcJfJaXnOncU6As-7FYG3x6mnN8MHzy0ecIaBhUDWxXsBV4u1TTu09piPnAeQO86bxuvU2FDx3w5g14U3778elL-PLz7Rq-0LXQlajkgurlmlUlE-tqvejrcrUkWj-zjTq2y-qoS70kqdhyKZlYqme2MDVnfMUEE5yzqlwX63LDaV2plZS0qUjDitFJGltY-3LKChYmxpHqjVivnhdWtmTj1N04nxsSz40u1Dn-qR27CCtmTUzxxpBMslNLvGthUB5w_27WrQbOwbtuOiHgjTZRyaDNPFMsxmDrD1aZ1I9tofwJeJMTzsPTEPxPUgl4M-mPwJtpC38HAAD__2_kn8k">