I recently revisited an old (2012) post
by John Regehr about undefined behavior, which highlights the following two examples.
It turns out that GCC can nowadays warn about both, at least in these simple cases. (Clang,
sadly, does not.)
Example 1:
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;
}