https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69296

            Bug ID: 69296
           Summary: Problem with associate and vector subscript
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrestelli at gmail dot com
  Target Milestone: ---

The attached code, when compiled with gfortran, prints

shape: 2

and then crashes printing "ai". The same code compiled with ifort
shows what I thing is the correct behaviour, namely

$ ./test
 shape:            2           3
 ai =            1         -10           3         -30           5         -50

Notice that gfortran considers "ai" to have rank 1, while ifort
correctly detects the rank 2.


program p
 implicit none

 integer :: j, a(2,6), i(3,2)

  a(1,:) = (/ (     j , j=1,6) /)
  a(2,:) = (/ ( -10*j , j=1,6) /)

  i(:,1) = (/ 1 , 3 , 5 /)
  i(:,2) = (/ 4 , 5 , 6 /)

  associate( ai => a(:,i(:,1)) )
  write(*,*) "shape: ", shape(ai)
  write(*,*) "ai = ", ai
  end associate

end program p

Reply via email to