$ cat matmul.f90 program main real, dimension(2,2) :: a real, dimension(4,2) :: c a = reshape((/ 1.0, 1.0, 0.0, 1.0/), shape(a)) c = 42. c(1:2,1:2) = matmul(a, transpose(a)) print *,c(1:2,1:2) print *,matmul(a, transpose(a)) print *,c(3:4,1:2) end $ gfortran matmul.f90 $ ./a.out 1.000000 1.000000 43.00000 44.00000 1.000000 1.000000 1.000000 2.000000 0.000000 0.000000 42.00000 42.00000 $ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../gcc-4.1/configure --prefix=/home/ig25 --enable-languages=c,f95 Thread model: posix gcc version 4.1.0 20050603 (experimental)
The problem is in the zeroing of the result, which assumes a packed return array. -- Summary: matmul does not deal with non-packed result Product: gcc Version: 4.1.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P2 Component: libfortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21926