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

    <tr>
        <th>Summary</th>
        <td>
            Just another example of using uninitialized variables without warning and removing code during optimization
        </td>
    </tr>

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

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

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

<pre>
    I found a (relative simple) case where clang/llvm optimizes code away because of using an uninitialized variable without issuing a warning. The optimization exists since LLVM 14.

```
__attribute__((noinline))
int func(int i, int x) {
 return i == 0 ? 1 : x+1;
}

int main() {
    int x;

 for (int i=0; i < 10; ++i) {
        x = func(i, x);
    }

 return x;
}
```

See https://godbolt.org/z/6jYMrrbaW ... the content of the main function is optimized to way and replaced by `unreachable`.

I know that the code is undefined behavior and the optimization is from the standard correct but applying such an optimization in -O1 without warning is (from my perspective) critical.

Potential duplicate to #78129 #72391 #49411
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVE2P4zYM_TXKhZjAlhJ_HHyYbBBgi120QIsWPQ1kmYm5lSVDH5Nkfn1BTzY7M7uB4VAJ9chHPlLHSCeH2IntTmz3K53T6EMXU6DJq7pZ9X64dp_h6LMbQIOQTUCrEz0jRJpmi0K2YHREOI8YEIzV7iTkwdrnCfycaKIXjGD8gKDP-go9Gp0jgj9CjuROoB1kR44SaUsvOMCzDqR7i3CmNPqcgGLMiyecdXDkTmv4a8Tv6DqRd4AXiilCJGcQvnz5-yuUm7Uo9qJ4vL2r4vYsx6cnnVKgPid8ehKyEbJxnpwlx4z4WdzIJThmZ4Rs2CQhPwEbF6Yt6t2rFwRMOTggEGov1B4KEOoAJQj1yK67Uqibq6j3b7NirEmTWzJ4iwhwi3O_-Pr70Qe4J6P2hVC7JewnKBdbyJ2QO_oJjD8XTu9Oh6kwjXsEdvmQ3ndil1_k_76er-8_EWFMaY5CPQp5EPJw8kPvbVr7wKp4EfJQffv3awi9_gfW6zWkEcF4l9AllgQfuR5LlktjKd5lNEDywBrSboCAs9UGB-ivIKoiu4DajKwbURXvOv8Z_nP-DGnU6RZuQIbNbsAjOYbAUT-TDwtw-igtinAMflr-iEm7QYcBjA8BTYI-J9DzbK8s0JjNyHp-f93Bw-_lXcw3CTOqkM0CPF1hxhBnNDxXy0AFSmS0fcfjD89VIm1hyLMloxNyQYRUdVNyv6WqpWpLNjbtpixXQ6eGVrV6hV1ZF3WpVFu0q7Grt32v6rrqVSM3qt62fdW0uNGtMYjmWK2ok4XcFLLYluW23LRrrcywbTTitpLVUG_FpsBJk13znHNzVzyk2DVFVdUrq3u0cdkpUjo8LxOMQkpeMaHjOw99PkWxKSyP7Q-URMli91uOCbTzacQAeNG8Z34sjF9vi_hThV9VMvlnPixNH3Jg-217VjnY7oNkKY25Xxs_3fbY7ethDv4bmiTkYeEThTwsfP8PAAD__4NOpy8">