http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14741
--- Comment #30 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- Since at least gcc 4.8.2, -floop-interchange is able to apply it to the test in comment 25 (see also pr60997): [Book15] f90/bug% gfortran-fsf-4.8 -Ofast pr14741.f90 -floop-interchange [Book15] f90/bug% time a.out 0.48877399999999999 10.239999999999826 0.492u 0.007s 0:00.50 98.0% 0+0k 0+0io 0pf+0w [Book15] f90/bug% gfortran-fsf-4.8 -Ofast pr14741.f90 [Book15] f90/bug% time a.out 3.9007499999999999 10.239999999999826 3.897u 0.015s 0:03.91 99.7% 0+0k 0+0io 1pf+0w However compiling it with -floop-nest-optimize --param loop-block-tile-size=xx, gives the following error (see comment 18) f951: warning: iteration 31 invokes undefined behavior [-Waggressive-loop-optimizations] f951: note: containing loop f951: warning: iteration 31 invokes undefined behavior [-Waggressive-loop-optimizations] f951: note: containing loop pr14741.f90:6:0: warning: iteration 31 invokes undefined behavior [-Waggressive-loop-optimizations] B=0.1D0 ^ f951: note: containing loop pr14741.f90:5:0: warning: iteration 31 invokes undefined behavior [-Waggressive-loop-optimizations] A=0.1D0 ^ f951: note: containing loop for any values of xx I have tested. If I add -fno-aggressive-loop-optimizations, the code segfaults (Access to an undefined portion of a memory object) at run time.