https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115863
--- Comment #5 from Sergei Trofimovich <slyfox at gcc dot gnu.org> --- (In reply to H.J. Lu from comment #3) > This may be fixed by r15-1954. Great find! That fix repairs `zlib` and `perl` for me. Here is the extracted example from zlib-1.3.1 for completeness in case it's useful to have a generic C example for test suite: // $ cat compress.c typedef unsigned long uLong; typedef unsigned int uInt; struct s { unsigned int ai; unsigned int ao; }; __attribute__((noipa)) static void init_struct(struct s * p) { p->ai = 0; p->ao = 0; } __attribute__((noipa)) static void do_struct(struct s * p, uLong sourceLen, uLong destLen) { uLong left = destLen; const uInt max = (uInt)-1; if (p->ao == 0) { p->ao = left > (uLong)max ? max : (uInt)left; left -= p->ao; } if (p->ai == 0) { p->ai = sourceLen > (uLong)max ? max : (uInt)sourceLen; sourceLen -= p->ai; } } __attribute__((noipa)) static void check_struct(struct s * p) { if (p->ai != 0xe) __builtin_trap(); if (p->ao != 0xea60) __builtin_trap(); } int main(void) { struct s v; init_struct(&v); do_struct(&v, 0xe, 0xea60); check_struct(&v); return 0; } Crashing with gcc r15-1936-g80e446e829d818: $ gcc -O2 -o bug compress.c && ./bug Illegal instruction (core dumped) $ gcc -O1 -o bug compress.c && ./bug <ok>