https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112346
Bug ID: 112346 Summary: Wrong code produced with -O2 Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- This program #include <ctype.h> char *SkipAName(char *s) { if (('A' <= *s && *s <= 'Z') || ('a' <= *s && *s <= 'z') ) { while (isalnum(*s)) { s++; } } return s; } int TestName(char *name) { while (*name) name++; return 0; } int StrICmp(char *s1, char *s2) { while (*s1 && *s1 == *s2) { s1++; s2++; } return *s1 - *s2; } int DoTable(char *s) { char *name, c; name = s; s = SkipAName(s); c = *s; *s = 0; TestName(name); *s = c; if (*s == '(') return 3; if (*s != ',') return 2; *s = 0; return StrICmp(name, "sparse"); } int main() { char buf[] = "sparse,C(1)"; return DoTable(buf); } shall return 0, but in GCC 13 with -O2 it returns 44. Online demo: https://gcc.godbolt.org/z/c6W33T1zK Related discussion: https://stackoverflow.com/q/77407156/7325599