http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28105
--- Comment #8 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-12-01 14:43:55 UTC --- AFAICS the patch I committed in #6 as r167317 only changes how the ALLOCATE statement is compiled. For automatic and static arrays, different codepaths are chosen. In principle we should be able to catch the example in #7 at compile-time. But intuitively that would require us to check overflow after constant propagation; I don't know how easy that would be to do and what other effects such a change might bring. Or, perhaps a simpler approach would be to generate the array setup code with runtime overflow checks, and rely on the optimizers to remove the test at runtime for constant bounds; that is, essentially what the ALLOCATE code does?