https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113551
Bug ID: 113551 Summary: Miscompilation with -O1 -funswitch-loops -fno-strict-overflow Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: yshuiv7 at gmail dot com Target Milestone: --- Code: struct obj { int __pad; int i; }; /* aborts when called with NULL */ int assert_not_null(void *); void bug(struct obj **root, struct obj *dso) { while (1) { struct obj *this = *root; if (dso == (void *)0) // should return here return; if (dso == this) return; // shouldn't reach here assert_not_null(dso); if (!&dso->i) break; } } // call like this: bug(&obj, NULL); Result: * -O1: ok * -O1 -funswitch-loops: ok * -O1 -fno-strict-overflow: ok * -O1 -funswitch-loops -fno-strict-overflow: abort