<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134566>134566</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Incorrect execution result of intrinsic assignment with an unallocated allocatable array
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
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
$
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVk1v4zgM_TXKhRhDpj8SH3LwtMhizrvY60K26dgDRQokuUn66xe0ncZI2k53LmsEiAySj--RtCTlfb83RFuRfRfZ80oNobNuaztjv7U_V5VtLluRy_kny7_J-d4asC20Wpk9iKQEjCMZSYEbmdfVuoopTlUcr2nTUlxUa8w3Rb3J47xer7GWG7kWWAjclaWruzwVslxmKOvauqY3ewgWRC531gWnDPwZlGmUawAlJmPaWEYYxVECP0wgd3QUVJi59Sa43vi-hknggUzwjI9PoAzDDkZpbWsVqIF5pSpN8KJczwuRS-g9NNT2hl08x82OnORAobNNBEKWf3XkqLWOvo4OAjcngdnllUvBqQyEjkCFoOqOGjg6u3fqwBRuSKc-dKOb79SRWCe_0PnoyI9deXPQ9kQOKjuYht1ELudsuYxg5gwvSg80m4fJd6b1-kbLMzzVnD1YqAhSFmlsgGRS24z5llD6q1B4hYojnoGJVGu1tiduv3I0Ygfy4VoPjtjx3PHij3YeDWbRt2eo7eHY67E_And0pnoYe-XIDzrMSbzZ7-M0r__BqC2kSMrl_M2IQpYH2wya4BALWQKEy5HgPC4BeLpoT45jkxLOkwtxKW5uvBT4ROdApvECN2euwxRxeR_ocgc0uk2Qb6kn2M1l_IKeFqN1xXgRuOE1Fl8N4Q4tQhbusHiu-OyMIinTa4ab7qXwzXmh9yRkyW7LmnInhsrZIfSGwE_SB_9W8ZPrA-PkAp8EMjkQuJ7GdPnxgEie2cID8WhlqPeR9KdIj9aJ1DjQo-Ns-CLV10-pvt4S_JrrA9SjdS73fX2FLK_bykH1ZkxYK62v1X8_-VF5z5kmzDuA5cZ9_4rpfETcf3HfIRK4U5EdAuf9oKfAB8M7jZiM-BB5qwskD5E34yh11DRS_LWG_XWX-T0Zn6q4PZ_quT2PaO-64X8Vybvnb7bpM3L_u9RVs02aIinUirbxOk2KIpFJvOq2mK2rOs7SDAtFOaUZ5TEVOVWFwrrKaNVvUWImU7mWyDER5m2VEGaqyrI2zjcilXRQvY60fjlE1u1XvfcDbeMkzfJ8pVVF2o_XKsR2OrKQb1huywHfqmHvRSp174O_QYQ-6PEuNh1y2TP8MLV1juoA9-fZR_ec6RagDHx0CVHOqctqcHrbhXD049a_E7jb96Ebqqi2B4E7pjT_fTs6-5PqIHA3SvQCd7PKly3-GwAA__-iYfZL">