https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107769
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|-flto with -Os/-O2/-O3 |[12/13 Regression] -flto |emitted code with gcc 12.x |with -Os/-O2/-O3 emitted |segfaults via mutated |code with gcc 12.x |global in .rodata |segfaults via mutated | |global in .rodata Ever confirmed|0 |1 Known to fail| |12.1.0, 13.0 Status|UNCONFIRMED |NEW Target Milestone|--- |12.3 Last reconfirmed| |2022-11-20 Known to work| |11.1.0 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed, reduced further, removing malloc and changing srand into a function inside the TU (with noipa attribute): [[gnu::noipa]] void hjj (unsigned int lk) { (void)lk; } void nn(int i, int n); [[gnu::noinline]] int ll(void) { return 1; } void hh(int* dest, int src) { if (!ll() && !src) hjj(100); (*dest) = 1; } void gg(int* result, int x) { if (x >= 0) return; int xx; xx = *result; hh(result, ll()); if (xx >= *result) nn(xx, *result); } void nn(int i, int n) { int T8_; if (n < 0) __builtin_exit(0); T8_ = 0; gg(&T8_, i); __builtin_exit(0); } void kk(int* x, int i) { hh(x, ll()); if (i < 0 || i >= *x) nn(i,*x); } int g__r_1 = 0; int main() { kk(&g__r_1, 0); return 0; }