The following program fails to compile. program bug implicit none integer, parameter :: nx=4,ny=4 real, dimension(nx,ny) :: f, g real, dimension(nx) :: x integer :: i x = cshift((/ (i, i = 1, nx) /), nx/2) * 2 g = spread(x, 2, ny) ! ! x and g above (which compiles) are equivalent to f below (which doesn't). ! f = spread(cshift((/ (i, i = 1, nx) /), nx/2) * 2, 2, ny) end program bug
kargl[236] gfc41 -o z -static f.f90 In file f.f90:9 f = spread(cshift((/ (i, i = 1, nx) /), nx/2) * 2, 2, ny) 1 Error: Incompatible ranks 2 and 1 in assignment at (1) -fdump-parse-tree shows ASSIGN x(FULL) __convert_i4_r4[[(((* _gfortran_cshift0_4[[(((/1, 2, 3, 4/)) (2) ((arg not-present)))]] 2)))]] ASSIGN g(FULL) _gfortran_spread[[((x(FULL)) (2) (4))]] ASSIGN f(FULL) _gfortran_spread[[(((* _gfortran_cshift0_4[[(((/1, 2, 3, 4/)) (2) ((arg not-present)))]] 2)) (2) (4))]] which suggests that the scalarization of cshift0 has set the rank to 2 instead of 2. -- Summary: Problems with SPREAD and/or scalarization Product: gcc Version: 4.1.0 Status: NEW Severity: normal Priority: P2 Component: fortran AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24168