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

    <tr>
        <th>Summary</th>
        <td>
            [LLVM] SIGSEGV with clang-trunk at -Os; Unexpected Behavior at -O1 vs Expected Infinite Loop at -O0 and gcc -O2
        </td>
    </tr>

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

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

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

<pre>
    The following code triggers a `SIGSEGV` when compiled with `clang-trunk` and `clang 19.1.0` using the `-Os` optimization level.
With `-O1`, the program exits with a return value of `64`. However, when compiled with `clang` `-O0` or `gcc` `-O2`, the program behaves as expected and enters an infinite loop.

Additionally, the behavior cases are also different on the `arm` backends.

```
#include <memory> 
unsigned long long a;
void b(unsigned long long *, int) {}
class {
public:
  short c[10];
} e;
int main() {
  for (size_t d;;)
    b(&a, e.c[d]);
}
```

Please see: https://godbolt.org/z/79fzqePEv


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VN-PozYQ_mvMyygI7ADhgYfNZXM9aas96drrY2XsAdwzNrUN2d2_vjIk6bZanRQ5ml_ffDP4M_de9QaxIcWRFKeEz2Gwrrlw07c2L5LWytfmtwGhs1rbizI9CCsRglN9j84DB1Jm3758_vb4-TspM7gMaEDYcVIaJVxUGGKC0Nz0u-Bm8yMmcSPvXsjrNE-z6J59xA8DxuDu2UefnYIa1RsPyhrQuKBOSXYi2cMfV-jdc07KjNBPa-HkbO_4CPiigt_ac3AYZmdg4XpGsF2sKvekzFL4xV5wQRerf0I88lg7rSyti0YvxN1NPyDQ4sAX9MA94MuEIqBcx0YT1rUZUKZTRgUEbe10HWo7H6RUcV6u9esNd8VT1oHgPsI6BK69Bam6Dh2aANbcVsfdGLm1XPxAI_1_sCPV7beZlCkj9CwRCPs04mjdK2GPsEVns94OCdqafjs4YcctuFgloSX08EEWoQ-RuDKB0BpIdSTVaasSmnu_elZzmlutBGFXdgB-sC6AIMUxz0hxuncj1QnwbikTYOTKEHq4NbjWd_Hz0INXb_hnABkr2JHQ-haHlTKhJY8EMY2dZGxE6_e9Pl7Wen7VyD2CRyTsAYYQJh_50zOh597K1uqQWtcTen4j9FzV3dvf-PVxeQ-RyIbJmtU8wSavGKVlVlRVMjSHmraSM16IKq_bOmMyYxXnbXVgeUn3VaIamtF9nlOaVbRmVVru61zIFgvGO9x3lOwzHLnSqdbLGHkkyvsZmzyvWJYlmreo_ap2Sg1eYI0SSqP4XROLdu3ce7LPtPLB_wsTVNDrM_H09P1XUpzgKvpNKu8EDjxAFC87wu_mfvePt_u7RnNYPDzeYl9uSniydtoStjeiFwJ2zzSZnW7-t2gVhrlNhR0JPUeO17_d5OxfKAKh53UyT-j5OvrS0H8CAAD__2nye7Q">