Array reverse slice
Euler-37 opened this issue · comments
Euler-37 commented
program main
implicit none
integer::a(2)
a=[1,2]
a(1:2)=a(2:1:-1)
write(*,*)a
end program main
$ lfortran --version
LFortran version: 0.35.0
Platform: Windows
Default target: x86_64-pc-windows-msvc
$ lfortran 1.f90
2
2
$ gfortran 1.f90 && a.exe
2 1
bug for reverse array slice
Ondřej Čertík commented
Good catch, thanks!
Gaurav Dhingra commented
I think this issue happens because there is an assignment to an ArraySection which is itself. e.g. the below program works:
program main
implicit none
integer :: a(2)
integer :: b(2)
a = [1,2]
b = [1,2]
a(1:2) = b(2:1:-1)
print *, a !> output is 2, 1
end program main
I'll try to see if I can fix this issue. The problem is in array_op
pass