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

            Bug ID: 67171
           Summary: [6.0 regression] sourced allocation
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mexas at bristol dot ac.uk
                CC: vehre at gcc dot gnu.org
  Target Milestone: ---

program z
implicit none

real, allocatable :: d(:,:), tmp(:,:)
integer :: i, errstat

allocate( d( 100, 2 ), source = 0.0, stat=errstat )

d(:,1) = (/ ( real(i), i=1,100) /)
d(:,2) = (/ ( real(2*i), i=1,100) /)

write (*,*) d( 1, :) 
call move_alloc( from=d, to=tmp )
write (*,*) tmp( 1, :) 
allocate( d( 50, 2 ), source = tmp(1:50,:) , stat=errstat )
write (*,*) d( 1, :) 
deallocate( tmp )

end program z 

Correct output in gfortran 5:

$ gfortran5 -Wl,-rpath=/usr/local/lib/gcc5 z.f90
$ ./a.out 
   1.00000000       2.00000000    
   1.00000000       2.00000000    
   1.00000000       2.00000000    

Wrong output in gfortran 6:

$ gfortran6 -Wl,-rpath=/usr/local/lib/gcc6 z.f90 
$ ./a.out 
   1.00000000       2.00000000    
   1.00000000       2.00000000    
   4.00000000       0.00000000    

This is on FreeBSD 10.1-RELEASE-p16 amd64

Reply via email to