https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112828
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2023-12-03 Status|UNCONFIRMED |NEW Keywords| |wrong-code CC| |anlauf at gcc dot gnu.org --- Comment #6 from anlauf at gcc dot gnu.org --- I get this crash with all gfortran versions (>= 7) on x86_64-pc-linux-gnu. Sometimes optimization needs to be enabled to see this. Replacing in reallocate the line character(LEN(array)), allocatable :: array_new(:) with the actual (constant) length fixes the issue, e.g. character(LEN=64), allocatable :: array_new(:) This may be a hint. In my tests the stat variable only needs to be accessed by the line if (PRESENT(stat)) it needs not be set explicitly. Compiling with -fsanitize=address gives at runtime: - when compiled with -O0: ==30489==ERROR: AddressSanitizer: requested allocation size 0x515f9880000 (0x515f9881000 after adjustments for alignment, red zones etc.) exceeds maximum supported size of 0x10000000000 (thread T0) #0 0x1457e8eb4527 in malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69 ... - with -Og and higher: ==30533==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x502000000071 at pc 0x152c5cbc8a79 bp 0x7fff0a124100 sp 0x7fff0a1238c0 WRITE of size 64 at 0x502000000071 thread T0 ... (details depend on optimization level).