------- Additional Comments From tkoenig at gcc dot gnu dot org 2005-04-15 17:24 ------- There's something rotten in the state of Denmark.
I've slightly modified Paul's test program with my patch, and this is what I got: program test_spread implicit none integer, parameter :: N = 100 integer :: I integer, dimension(N) :: source integer, dimension(N,N) :: sink, check,c1,c2 source =(/(i, i=1,N)/) check = spread( source , 1 , N ) PRINT *,"first 4x4 elements with DIM=1" write(*,'(1x,4I4)') check(1:4,1:4) check = spread( source , 2 , N ) PRINT *,"first 4x4 elements with DIM=2" write(*,'(1x,4I4)') check(1:4,1:4) c1 = spread(source, 1, N) c2 = spread(source, 2, N) sink = spread( source , 1 , N ) * spread( source , 2 , N ) PRINT *,"The product using temporaries" write(*,'(1x,4I4)') sink(1:4,1:4) PRINT *,"The product using fixed arrays" sink = c1 * c2 write(*,'(1x,4I4)') sink(1:4,1:4) end program test_spread $ gfortran test_spread.f90 $ ./a.out first 4x4 elements with DIM=1 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 first 4x4 elements with DIM=2 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 The product using temporaries 100 0 0 0 200 0 0 0 300 0 0 0 400 0 0 0 The product using fixed arrays 1 2 3 4 2 4 6 8 3 6 9 12 4 8 12 16 I am not applying my patch for the moment. A segfault is better than a silently generated wrong result :-( Investigating further. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18495