------- Comment #2 from tkoenig at gcc dot gnu dot org 2008-07-25 08:15 ------- This works now, with the fixes for matmul bounds checks (PR 36341):
$ cat mat.f90 program mat implicit none complex, allocatable :: a(:,:),b(:,:) complex :: d(1,1) allocate(a(4,1),b(4,1)) a = cmplx(0.5,2.0) b = cmplx(2.0,0.5) d = matmul(a,transpose(b)) deallocate(a,b) end program mat $ gfortran -fbounds-check mat.f90 $ ./a.out Fortran runtime error: Incorrect extent in return array in MATMUL intrinsic for dimension 1: is 1, should be 4 $ cat mat-2.f90 program mat implicit none complex, allocatable :: a(:,:),b(:,:) complex :: d(1,1) allocate(a(4,1),b(4,1)) a = cmplx(0.5,2.0) b = cmplx(2.0,0.5) d = matmul(a,b) deallocate(a,b) end program mat $ gfortran -fbounds-check mat-2.f90 $ ./a.out Fortran runtime error: Incorrect extent in return array in MATMUL intrinsic for dimension 1: is 1, should be 4 The case of user-defined functions also works: $ cat f.f90 module a contains function f(x) real, intent(in) :: x real, dimension(3,3) :: f f = x end function f end module a program main use a real, dimension(2,2) :: b b = f(1.0) end program main $ gfortran f.f90 f.f90:13.3: b = f(1.0) 1 Error: Different shape for array assignment at (1) on dimension 1 (2 and 3) Closing. -- tkoenig at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29572