<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62980>62980</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Incorrect execution result of using the array defined in FORALL construct with scalar-mask-expr
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 17.0.0(f6c4808d95221a5838e14474d95c6fe85bb1488a)
```

In Flang, the value of the array used in the scalar-mask-expr(a(i)>1) appears to reflect the value of the array definition in the `FORALL` construct.

The following are the test program, results of Flang-new, Gfortran and ifort compilation and execution.

z033.f90:
```fortran
program main
 integer,dimension(4)::a=(/11,-2,21,1/)
  write(6,*) "before a = ", a
  forall(i=1:3,a(i)>1)
     a(i+1) = 10
  end forall
 write(6,*) "after  a = ", a
end program main
```

```
$ flang-new -flang-experimental-exec z033.f90; ./a.out
 before a =  11 -2 21 1
 after  a =  11 10 10 10
$
```

```
$ gfortran z033.f90; ./a.out
 before a =           11          -2          21           1
 after  a =           11          10          21 10
$
```

```
$ ifort z033.f90; ./a.out
 before a = 11          -2          21           1
 after  a =           11 10          21          10
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVVGPozYQ_jXmZQSyx8DCAw_ZpFQnnVSpqvpuYEh8dXBkm9u9_vrKQDa7ubS6Vo1QYo_xN983Y39R3uvjRNSw4pkVh0TN4WRdY0-TTccvSWeHbw0r-fbwA-O738l5bSewI4xGTcd0ohdgcgfiKeMZZ1iNZZ9XvBrqAlGoopIViTx_yoe66MuRqqLrRF5VimG9Qt5lWL8_TdBGfIZ7CCeCr8rMFLPGiXJOfYPZ0wB6WiK-V0a59Kz8Hym9XhzDmKDSMYn8STCsQV0upJyHYMHRaKgPfwc80KgnHaLMDZ6VvP3l193nz6zk0NvJBzf3IXtP-LcTwWiNsS96OoJytGwM5ANcnD06dY5SHPnZBB_ztdfyxfjPo3XBqQnUNICOE-jt-aKNWmjEKL1SP8fZh7R_cimzseZM7u6quSGu0Y0CnJXeIqCnQEdyDPeDPtMUu8qwypeK7ZjcKSYPDCuGrRAM9yky3GMcCYbtW_MAXpwOxLAqGe4Z7mKpGWJHo3UECpg8xHkUqa5bRuuUMUt_5EEwuZMM93f9ur4LANvK89LGiCf4dZWm4Yq2Rh6zUWMgBw_ZRITvq_PwTN4HMX93B9J1SK8XcrGeQZk0tgxuHXqGjGGrMjuHje2HKoEQkCKgALEtf6AdlwVfnzcC_47t8XrKfpzT20eI2zjF2xjF-5ceEn-IIfgHjP-sab0sPyzof5Jxx_6dqn-WkQyNHGpZq4QaUVaFzDEvyuTUlHVddAMvhryL1lk9Vbweh2LkuXiSRU-JbpCj5AXWvMx5UWbFUydlwbHDUcqxI5ZzOittMmO-njPrjon2fqamxLriiVEdGb8YPeJyVJncjc5OgaYh3ojikLgmbk27-ehZzo32wd_Agg5m-aNYbbk4wKept85FH32zps3for3NPvrgnamuhr1a6c1H4UWH03cWnszONKcQLj76UbSc9qjDae6y3p4ZtpHZ9pNenP1CfWDYLpo9w3aR_VcAAAD__zkB3_E">