https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66310
--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- I have found that there is a practical limit of 2**28-1 on the size. The test case: program p character, parameter :: z = 'z' print *, repeat(z, (268435456)) ! 2**28 end gives when compiled: f951: out of memory allocating 18446744073441116160 bytes after a total of 569344 bytes The binary representation of the large number is: 1111111111111111111111111111111111110000000000000000000000000000 The memory is exceeded during some allocation during the resolution phase in resolve.c. For now I propose setting the limit in gfc_simplify_repeat to 2**28-1 which then catches the error condition and is more than adequate. I would then like to open a new PR regarding the above error message. It may be that we need to set a limit in gfc_get_character_expr to catch this more globally. In many places we are using signed int rather than size_t and we can get all kinds of problems from this.