https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80975
--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Restricted to the library version, the inline version is OK: ig25@linux-d6cw:~/Krempel/MMZero> cat t1.f90 program bogus_matmul implicit none real :: M(3,0), v(0), w(3) w = 7 w = matmul(M,v) print *,w if( any(w .ne. 0) ) then call exit(1) end if end program bogus_matmul ig25@linux-d6cw:~/Krempel/MMZero> gfortran t1.f90 && ./a.out 7.00000000 7.00000000 7.00000000 ig25@linux-d6cw:~/Krempel/MMZero> gfortran -O t1.f90 && ./a.out 0.00000000 0.00000000 0.00000000 ig25@linux-d6cw:~/Krempel/MMZero>