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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Execution of sections construct with firstprivate and lastparivate clauses does not terminate
        </td>
    </tr>

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

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

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

<pre>
    ```
Version of flang-new : 18.0.0(103811a27abcbcc6792c88dcdd30034e5cc8adc3)
```

Execution of `sections` construct with `firstprivate` and `lastparivate` clauses does not terminate.
When either the `firstprivate` or `lastparivate` clause is specified, execution is terminated.

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

snfmm251_6.f90:
```fortran
program main
  call test01()
  print *,'pass'
end program main

subroutine test01()
  integer::ja
!$omp parallel sections firstprivate(ja) lastprivate(ja)
  do i=1,5
     ja=0
     ja=ja+1
  end do
!$omp end parallel sections
  write(6,*) "finish parallel region"
end subroutine test01
```

```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp snfmm251_6.f90; ./a.out
  C-c C-c
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snfmm251_6.f90; ./a.out
 finish parallel region
 pass
$
```

```
$ export OMP_NUM_THREADS=2; ifort -qopenmp snfmm251_6.f90; ./a.out
 finish parallel region
 pass
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VUuP2zYQ_jXUZWCBHFkPH3Sw13F72SZo0_a4oKmRRIMiVZLKpv--kGyvd51sgQJtAT_Aj5r5vnlKhqA7S1SzfMfyfSKn2Dtfu966VXtKjq75s2YFv3z4nvHtb-SDdhZcC62RtltZegaWbUFUKU85w0rwrBJCYimP6qhUUW5QVVWjmibjPFtTrlQlG5Ux3Jxd3jGcfz98JTXFCxMreCA1nwIrOChnQ_STivCsYz_fttqHOHr9RUaan5C2mWEjQxzlDVZGToECNI4CWBchkh-0lZHSM-vvPVkgHXvyEHv6nmvn3_cMOkAYSelWU8PwAeglCh1uZE36OtLPPUHrjHHP2nYgPS3MkUKE0bvOy2H2dLgmez780DofvbRLnHo-gHLDqI2cuRgebryewmTiG8Jg22HAXDwVabvhLNveleHi_IxeJMAg9QUBUNKYRSAXDKuXOgKMXtsIDLcMHxiWowyBYXm-JdvAt84uiqajd1PUlr7rVttIHflZabY9yYslCoZrN4wwSi-NIQPXHoE3NcPqJBluYCnZW-xK0DjQLNsLhg_5FQOAk2TZnt8Ds-VOXNE5rMbdS1qCvZd1NXn2epFQLFnaztoYYqutDv3NylO31BJv6fs2Te_Pzz2Ia6Cv49wpHx8_Pf306-PT5x9__rDd_8KyPbJs92qaV60byQ4j3DfKDlKGB5m6KV5jeVip-ftC8m8q6q5d_g8EvZPF8-XSj_-F0vMIrv74v2QmTZ01m2wjE6pFyfm6EDwTSV9vGlIlLwUVKFFWmLcFZlKUvBClanOe6Bo5ZkIgnyEh0krJthUbka1bjkVTsjWnQWqTGvNlSJ3vEh3CRHWJFa4TI49kwvK6QFw6hmXbc9Rzp-b7xNez4eo4dYGtudEhhpurqKNZXjbLNmP5nuW7jyPZx08s38Oblf8yy3fL_vVoL-vv9Sb-mwWfTN7UfYxjmNcIHhgeOh376ZgqNzA8zBovf6vRuxOpyPCwxB4YHpbw_woAAP__eWYn5Q">