https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111730

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note you can reproduce the same warning with ( -O2 -fno-code-hoisting
-fno-tree-loop-im -fno-tree-pre):
```
// #include <stdlib.h>

typedef long unsigned int size_t;
extern void *malloc (size_t size) __attribute__ ((__malloc__));
int *t;
void foo(int x) {
    // if (x < 1) return;
    for (int i = 0; i < x; i++) {*t = i;}

    char *a = malloc(x);

    for (int i = 0; i < x; i++)
        a[i] = 0;

    while (a[x - 1]) {*t++;}
}
```

I still think you should add a check for x being negative to fix the
code/warning. Unless you have a unreduced testcase which has the test before
and still able to produce the warning, this will most likely be closed as
invalid.

Reply via email to