https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108353
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> The for (; j; j = j + 9) loop invokes undefined behavior:
>
> t.c: In function 'g':
> t.c:11:17: warning: iteration 396462472 invokes undefined behavior
> [-Waggressive-loop-optimizations]
> 11 | for (; j; j = j + 9) {
> | ~~^~~~~~~
> t.c:11:12: note: within this loop
> 11 | for (; j; j = j + 9) {
> | ^
Here is the testcase without the overflow behavior and also a full link
testcase:
#include <limits.h>
enum { a } b();
int d;
int e;
int f;
void foo();
[[gnu::noipa]]
void bar49_(void){}
[[gnu::noipa]]
void(c)(void){}
static short g(int h, int i) {
int j = 2874288693, k = 1;
if (h)
for (; j < INT_MAX-18; j = j + 9) {
f = 0;
for (; f <= 1; c())
k = 90;
}
i = k;
for (; e; ++e) {
if (i)
continue;
foo();
i = b();
}
return 4;
}
int l() {
bar49_();
return 1;
}
int main() { d = d || g(d, l()); }