Runtime checks are OK, compile-time checks are better. $ cat sum.f90 program main real, dimension(3,3) :: a real, dimension(2) :: b a = 21. b = sum(a,dim=1) end program main $ gfortran -fbounds-check sum.f90 $ ./a.out Fortran runtime error: Incorrect extent in return value of SUM intrinsic in dimension 1: is 2, should be 3 $ cat product.f90 program main real, dimension(3,3) :: a real, dimension(2) :: b a = 21. b = product(a,dim=1) end program main $ gfortran -fbounds-check product.f90 $ ./a.out Fortran runtime error: Incorrect extent in return value of PRODUCT intrinsic in dimension 1: is 2, should be 3
-- Summary: Missing compile-time checks on sum and product Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org OtherBugsDependingO 27766 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36670