http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49103

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-05-21 
23:11:01 UTC ---
Reverting revision 169083 on trunk fixes this pr (see
http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01442.html for its motivation).
Further reduced test:

!----------------------------------
module dg_grid

implicit none

integer :: par_world_dims = 3

type world_t
   integer :: dims
   real(kind=8), dimension(:), pointer :: lengths
end type

contains

subroutine grid_new(grid)
   type(world_t), intent(inout) :: grid

   grid%dims = par_world_dims
   call grid_faces(grid)

end subroutine

! Start looking here: This is the routine that gives trouble.
subroutine grid_faces(grid)
   type(world_t), intent(inout) :: grid

   integer :: dimi, bordi
   integer, dimension(par_world_dims-1) :: fgrades
   integer, dimension(par_world_dims-1) :: fbasegrades

   do dimi=1,grid%dims-2

      ! The bug makes those two arrays exchange values temporarily.
      fbasegrades = (/ 1, 1 /)
      fgrades = (/ 2, 2 /)
      do bordi=1,2
         write(*,*) 'Here is the bug. The grades should be (2 2):', fgrades
         write(*,*) 'Compare the base grades:', fbasegrades
      end do
      write(*,*) 'grades again', fgrades

   end do
end subroutine

end module

program test_gcc46gridbug

use dg_grid

implicit none

type(world_t) :: grid

call grid_new(grid)

end program
!----------------------------------

Reply via email to