https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66310
--- Comment #3 from Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> --- I do agree, that some extra temporary data is necessary and there should be a practical (high) limit for something like that. Let the helper buffers be five or ten times the amount of the effectively written data. That's OK. But it's not a billion times as suggested by the huge number 18446744065119617024. Something IS going wrong here. --- Indeed, there is an actual limit at about 2^28 = 268435456 for the second case. That's plenty enough. But the point is (sorry for being late) : $ cat zlim_hd8m.f90 program p character, parameter :: z = 'z' print *, repeat(z, 268435450) end $ gfortran zlim_hd8m.f90 $ a.out > l $ wc l 1 1 268435452 l $ cat zlim_hd8p.f90 program p character, parameter :: z = 'z' print *, repeat(z, 268435460) end $ gfortran zlim_hd8p.f90 f951: out of memory allocating 18446744073441116164 bytes after a total of 430080 bytes --- For the first test case the limit is just below 2^31. This is really enough. No code change is needed, IMO. Only the message "invalid memory reference" was misleading the first time, therefore a reduction and investigation of some variations. Thank you.