https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83540
Bug ID: 83540 Summary: [8 Regression] Invalid code with MATMUL, -fno-realloc-lhs -ffrontend-optimize Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: anlauf at gmx dot de Target Milestone: --- The following code crashes at runtime: ! Bug with "-fno-realloc-lhs -ffrontend-optimize" program gfcbug142 implicit none real, allocatable :: b(:,:) integer :: n = 5 allocate (b(n,n)) call random_number (b) print *, shape (matmul (b, transpose (b))) end program gfcbug142 % gfc-8 -g -fno-realloc-lhs -ffrontend-optimize gfcbug142a.f90 && ./a.out Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0xffffe3ff in ??? #1 0x8048b77 in gfcbug142 at /work/DWD/git/dace_code/gfcbug142a.f90:8 #2 0x8048dd2 in main at /work/DWD/git/dace_code/gfcbug142a.f90:9 Segmentation fault (core dumped) Adding -fcheck=all: Fortran runtime error: Incorrect extent in return array in MATMUL intrinsic for dimension 1: is 0, should be 5 Error termination. Backtrace: #0 0x8048a7b in gfcbug142 at /work/DWD/git/dace_code/gfcbug142a.f90:8 #1 0x804950d in main at /work/DWD/git/dace_code/gfcbug142a.f90:9