http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50937
--- Comment #3 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-10-31 18:24:14 UTC --- >From the metadata, it seems you're using version 4.4.3, where the overflow check when calculating the size to allocate was a bit stupid. Basically it did the calculation, and if the result was negative, overflow was detected. But this check missed the cases where the calculated values would wrap around to a positive value again. I believe this is what you're seeing when some of the intermediate values succeed. In current versions of the compiler, overflow check is bit smarter. See PR 28105. Also, as Steve Kargl hinted at, many operating systems allow memory to be overcommitted. I.e. allocating memory succeeds, but the program is killed later on if it actually tries to use that memory. Gfortran has no checks whether the amount of memory you try to allocate is some reasonable fraction of the memory installed in the machine, it just does what you tell it to do.