| Issue |
71368
|
| Summary |
[Flang] Incorrect execution result of subarray operation passed to subroutine
|
| Labels |
flang:frontend
|
| Assignees |
|
| Reporter |
ohno-fj
|
```
Version of flang-new : 18.0.0(1c876ff5155c4feeb2b2885eb3e6abda17c4b7f4)
```
The result of subarray operation passed to `subroutine` is incorrect.
When I specify `-flang-experimental-hlfir` at the compilation, I can avoid the execution error.
The following are the test program, Flang-new, Gfortran and ifort compilation result.
target_tp01_3.f90:
```fortran
module m
contains
subroutine sub(a_arg,b_arg,c_arg)
integer, dimension(:),target:: a_arg
integer, dimension(:),target:: b_arg,c_arg
a_arg = b_arg + c_arg
end subroutine sub
end module m
program main
use m
integer,dimension(50)::x
integer,pointer :: a_pointer(:)
allocate (a_pointer(4))
a_pointer = (/100000,2,300000,40/)
call sub (a_pointer(2:3),a_pointer(1:2),a_pointer(3:4))
write(6,*) "a_pointer(3) = ", a_pointer(3)
x(a_pointer(3))=1
print *,'pass'
end program main
```
```
$ flang-new target_tp01_3.f90; ./a.out
a_pointer(3) = 400040
Segmentation fault (core dumped)
$
```
```
$ flang-new target_tp01_3.f90 -flang-experimental-hlfir; ./a.out
a_pointer(3) = 42
pass
$
```
```
$ gfortran target_tp01_3.f90; ./a.out
a_pointer(3) = 42
pass
$
```
```
$ ifort target_tp01_3.f90; ./a.out
a_pointer(3) = 42
pass
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs