Вот нашёл смачный пример, сильно машет на твой: https://blog.regehr.org/archives/767
Winner #1
Amonakov submitted this code:
enum {N = 32};
int a[N], pfx[N];
void prefix_sum (void)
{
int i, accum;
for (i = 0, accum = a[0]; i < N; i++, accum += a[i])
pfx[i] = accum;
}
This function forms a bit of an argument against the very terse style of for-loop afforded by C which (in my opinion) makes the undefined behavior harder to see than it might otherwise have been. The undefined operation here is reading a[32]. Recent versions of GCC, apparently as a consequence, decide that the loop exit test can be removed, giving an infinite loop that triggers a segfault when i becomes large enough.
"Неопределённое поведение здесь - это чтение a[32]. По-видимому, из-за этого недавние версии GCC заключают, что проверка окончания цикла может быть удалена, и получается бесконечный цикл..."