https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122537
Bug ID: 122537
Summary: wrong code at -O3 with -fwrapv
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: iamanonymous.cs at gmail dot com
Target Milestone: ---
This programs prints 70409304 at -O3 with -fwrapv and prints 1 at -O0/1/2/s:
int printf(const char *, ...);
int a, b;
int main() {
int c = 61;
int d = 61;
c += 8;
while (c + a - 80 >= d + a - 80) {
c -= d;
b++;
}
printf("%d\n", b);
}
Compiler Explorer: https://godbolt.org/z/n1Tev4zbx