https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69368
--- Comment #67 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- > > How can K(1) and K(2*1) be the same without using undefinedness explicitely? > They can't, but why does that matter for undefined behavior? > The CSE code in DOM doesn't try to analyze the array indices at all, it is > enough for it to prove that in valid program they must be all same. How can you "prove" that I and 2*I are the same in a valid program? > Whether the compiler could with additional efforts prove they are different or > not (it can't e.g. without LTO and without seeing caller that passes two > different variables). If you trust COMMON /BLK/ K(1) then FOO = K(I) + K(J) + K(2*I) + K(2*J) is invalid for any value of I and J: K(I) + K(J) is valid iff I=J=1, then the access to K(2) is out of bound, hence invalid.