<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/155481>155481</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Incorrect result of `ASSOCIATED` when the pointer is associated with zero sized storage sequence
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:runtime
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DanielCChen
</td>
</tr>
</table>
<pre>
Consider the following code:
```
type base
end type
type, extends (base) :: child
integer(8) :: something
end type
class (*), pointer :: x, x1(:)
type (child), target :: c1, c2(10)
x => c1%base
x1 => c2%base
print*, associated (x, c1%base)
print*, associated (x1, c2%base)
end
```
Flang outputs `T T`, but the expected output should be `F F` as the standard requires none zero sized storage sequence for intrinsic `ASSOCIATED` to return true.
```
Case (v): If TARGET is present and is a scalar target, the result is true if and only if TARGET is not a zero-sized storage sequence and POINTER is associated with a target that occupies the same storage units as TARGET.
Case (vi): If TARGET is present and is an array target, the result is true if and only if POINTER is associated with a target that has the same shape as TARGET, is neither of size zero nor an arraywhose elements are zero-sized storage sequences, and occupies the same storage units as TARGET in array element order.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVNFu4zYQ_BrqZRGDoiJZetCD6sRFXnrFnX-AFtcSC5rUkavEua8vSMt2Lu0FOcOALXF2dmaHpAxBDxaxZeUfrHzI5Eyj8-2DtBrNZjOizfZOvbYbZ4NW6IFGhIMzxr1oO0DvFLKiY7xjFV--vAMAoNcJYS8DLs9oVXoXoTcEExvAE6FVAZioE140ECmLDvpRG7Wg40dbwgE9E3X9BhXcEWnUdvhlp97IkPiZ6JhoYtPJRTJ_4TjFd6c8QooE-UllLD1rOReT9APSVWUe3_WCiTrnP9WegBUPrHhMkPLNME75dUXcVpbFyWtLSekGZAiu15JQRQ1J5Y0rtfoIfhX2Bo9WvUuL8W5rpB3AzTTNFIBVfAe7uCg2sJ8pZY6nCftIfEZBGN1sFOwxwrewZRUHGRI0kLRKegUev8_aYwDrLMIP9A6C_oEKAjkvB4SA32e0fdxRPqbrtQ26j4zdt29fNk_d7vEhEpMDjzR7C-RnXL0zsJEhRfQcHRYdPB1g133983EHOsDkMaAlkFbFRwmhl0b6JcOU5ojgMcyGIiA2AH1IeGfNa_x_Y7OOQCYnd79wEuv-_vL01-7xa-p3S-RF0wjysnlolASu7-dJ4zI2ecQr32w1xeql9-qc09Wp_oxVC9J7-fpbVj8tfZRvVY9ywpva2CoOCzWN6MEdUuznDWCdvyp7GV1AQINHtNGtx49GG9IOj1o_OzXQlxEsPcB5hf79_slUW6imaGSGbb4uK1Gsy6rJxlYoybkoe1zX_fpQ5TWvyopzLhXnvNmXmW4FFyWvRZU39xVvViUWZc1lI4Rcr1XdsHuOR6nNypjn48r5IdMhzNjmZXlf55mRezQh3b1CHOIhZEXnZ0v6iEyIeCH7Npbe7echsHtudKBwIyNNJl3d59ryAZ5s77zHni45u8N_j9PLiDYN73IL_k_aH5zWbPamHYmmkC7LLRPbQdM471e9OzKxjfKWn7vJu3-wJya2yXhgYrt4f27FvwEAAP__vucLjw">