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

    <tr>
        <th>Summary</th>
        <td>
            Wrong code at -O2/3 since `clang-14.0.0`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          jun-wei-zeng
      </td>
    </tr>
</table>

<pre>
    Compiler explorer: https://godbolt.org/z/97Yv6dEa7

I compiled the following code with `clang-15.0.0 and above version` at `-O2/3`, and the program output `nothing` and return `48`. And when I compiled with `clang-14.0.0` at `-O2/3`, and the program output `1` and return `0`.

So, this bug exists in `clang-14.0.0 and above version`. 

If the code is compiled correctly, the execution should output `nothing` and return `0`.


```c
$ cat test.c
int printf(const char*, ...);
union a {
  int d, b[4];
};
int main() {
  union a c = {0};
  int d = 0;
  for (; d < 4; ++d)
    if (c.b[d])
        printf("1\n"); 
}
$
$ clang-16.0.0 -O1 test.c; ./a.out
$ echo $?
0
$
$ clang-16.0.0 -O2 test.c; ./a.out
$ echo $?
48
$
$ clang-16.0.0 -O3 test.c; ./a.out
$ echo $?
48
$
$ clang-14.0.0 -O2 test.c; ./a.out
1
$ echo $?
0
$
$ clang-16.0.0 --version
clang version 16.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
$
$ clang-14.0.0 --version
clang version 14.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU2v4yYU_TXXmytbGH8lCy-Sl1rqahatVHVVYcA2UwIR4JfM_PoK25mkb0Z9Hc1EkT845x7OPRbAvFejkbKF6gjVKWFzmKxrP84mvUqVfpZmTHorPrUv9nxRWjqUt4u2TjooDjiFcPFQHIB2QLvRit7qkFk3Au0-A-32zZ-vtfiFNUBOQA7r9Vfkq5bAMEkcrNb2qsyI3AqJVxUmhJpwzcyY5lVGMoLMCGS9fZX4Kp1X1kBNkIXISz9QoF0BNQH6shCj6MXZ0bEz2jlc5oVnbJiUGZdCI9DJMDsTgXIHNcnwYAReJ2nwyd4bL2X08v0z51_PGVWy50x-s1EjTMpjP48ob8oHj8q8nf2bSWT4r3iHxccSpvKPZrh1TvKgP60zSZQ3yeegrEE_2VmL_xPWV8a3a03WP9_eaYmcBQzSh2wbUybgxSkTBqA7bo0PyCfmgB6ioSzLgO6hOK7k2URfDKHZBhBjvYjUHqpjCdXpCxmax3NknZkyQHdA98_1d0mOUJwiQJ7rNv0FI0-jg3UYtYrjAr5gGR-BHoEeRXS88RDVEIk8i_ZEtPcMxt-X5oHSHKoXA5SuPeOjj3t8Tzmun79ePn_6Ib-HWhwxA9qxzM7hwZZ8shjri24dJO9L0u-ULHfvaxY_UbN832f-Qwmk97W04At2X164clbkd-ZGGeLGd9vVf9VlOpu_jb2aVCsz39LRzBtvcpIJPFshdWRfrFe3d_v7Txflz3VxX6_rayLaQuyLPUtkmzckr8meNjSZWtFXpG5YJQmXTT8IIgaxI7ypm6YeOJOJaimhRU5JkRd5WdCM5NXQFznZVz3dDWwPJZFnpnSm9es5ngyJ8n6WbVPSkiSa9VL75eyh1MgrLmBcF9UpcW2sSft59FASHXfEh0pQQcv2D2fv5wYLuG3I6JXh8hv7djI73b45slSY5j7j9gy0i-LbLb04-1HyALRbLHmg3WL5nwAAAP__mN0E4A">