https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106078
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-06-24 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Jan Hubicka from comment #1) > This is version that does not need -fnon-call-exceptions > If called test (NULL, 0) it should be indefinitely increasing val rather > then segfaulting. Seems clang gets this one right. > > int array[10000]; > volatile int val; > int test(short *b,int s) > { > for (int i = 0; i<10000;i++) > { > for (int j = 0; j < 10; j+=s) > val++; > array[i]+=*b; > } > } For this one it's PRE hoisting *b across the endless loop (PRE handles calls as possibly not returning but not loops as possibly not terminating...) So it's a different bug.