Issue |
134566
|
Summary |
[Flang] Incorrect execution result of intrinsic assignment with an unallocated allocatable array
|
Labels |
flang
|
Assignees |
|
Reporter |
ohno-fj
|
```
Version of flang : 21.0.0(06cb7b1e14a117e8fe19b72689c8616c772c0807)/AArch64
```
According to `Fortran Standard 2023 : 10.2.1.3 Interpretation of intrinsic assignments`, an `unallocated allocatable variable` is defined as an allocation method.
Therefore, an `unallocated allocatable variable (w%yz)` in the attached program is allocated with the shape of the _expression_ with the lower bound of `w%yz`.
The value of `ubound (w%zz)` is expected to be 4, not 3, and the value of `lbound (w%zz)` is expected to be 2, not 1.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
sngg146c_2.f90:
```fortran
module m1
type x
integer:: x1
end type x
type,extends(x):: y
integer:: y1
end type y
type xx
type(y),allocatable:: yv(:)
type(y),allocatable:: zz(:)
type(y) :: yz(2:4)
end type xx
type(xx):: w
end module m1
subroutine s1
use m1
write(6,*) 'ubound(w%yz) = ', ubound(w%yz)
write(6,*) 'lbound(w%yz) = ', lbound(w%yz)
w%zz = w%yz
write(6,*) 'ubound(w%zz) = ', ubound(w%zz)
write(6,*) 'lbound(w%zz) = ', lbound(w%zz)
end subroutine s1
program main
call s1
write(6,*) 'pass'
end program main
```
```
$ flang sngg146c_2.f90; ./a.out
ubound(w%yz) = 4
lbound(w%yz) = 2
ubound(w%zz) = 3
lbound(w%zz) = 1
pass
$
```
```
$ gfortran sngg146c_2.f90; ./a.out
ubound(w%yz) = 4
lbound(w%yz) = 2
ubound(w%zz) = 4
lbound(w%zz) = 2
pass
$
```
```
$ ifx sngg146c_2.f90; ./a.out
ubound(w%yz) = 4
lbound(w%yz) = 2
ubound(w%zz) = 4
lbound(w%zz) = 2
pass
$
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs