https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122012
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note a better non uninitialized testcase:
```
#include <stdlib.h>
#include <stdio.h>
void __attribute__ ((noinline))
test(int step){
char *buf = malloc (50);
char *p = buf;
while (p < &buf[50]){
p += 3;
printf("%ld\n", __builtin_object_size (p, 2));
p += step;
}
free(buf);
return;
}
int main() {
test(3);
}
```
>From https://gitlab.alpinelinux.org/alpine/aports/-/issues/17416 .
And yes these 2 are the same issues.
In this testcase we have:
p_10 = p_4 + 3;
_1 = __builtin_object_size (p_10, 2);
...
p_13 = p_10 + _2;
Where p_4 is defined from:
# p_4 = PHI <buf_8(2), p_13(3)>
In the one from comment #0 we have:
# t_2 = PHI <t_8(5), t_4(D)(2)>
_10 = __builtin_object_size (t_2, 2);
t_8 is defined from:
t_8 = t_2 + _1;
goto <bb 3>; [100.00%]
Notice how this is ptrplus with a non-constant increment.
That is where the ICE comes from and what the patch fixes too.