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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Incorrect execution result of a do-variable in critical construct which exists in parallel construct with default(none) clause
        </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-new : 18.0.0(0fe86f9c518fb1296bba8d66ce495f9dfff2c435)
```

If `critical` construct exists in `parallel` construct with `default(none)` clause, a `do-variable` has an incorrect value after executing `parallel` construct. 
A `do-variable` is `private` according to the specification in `Section (2.15.1.1) of OpenMP 4.5`, so the values of k1 and k2 are expected to be 1. 
Changing `critical` construct to `sections` construct has the same result.

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

snfm_omp_array_do_011.f90:
```fortran
program main
 integer::k1,k2
  k1=1; k2=1
!$omp parallel default(none)
!$omp critical
  do k2=1,10
     do k1=1,10
     end do
  end do
!$omp end critical
!$omp endparallel
  write(6,*) "k1 = ", k1, " k2 = ", k2
end program main
```

```
$ export OMP_NUM_THREADS=2; flang-new -fopenmp snfm_omp_shared_13_011.f90; ./a.out
 k1 =  11  k2 =  11
$
```

```
$ export OMP_NUM_THREADS=2; gfortran -fopenmp snfm_omp_array_do_011.f90; ./a.out
 k1 =            1 k2 =            1
$
```

```
$ export OMP_NUM_THREADS=2; ifort -qopenmp snfm_omp_array_do_011.f90; ./a.out
 k1 =            1  k2 = 1
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VcGS4jgPfhpzUZGyHRKSAwcafv6dQ-9M7czulXIcmXhI7KztdPe8_ZaTQNN0T-1llqIglhTpk_RZEt7rk0HckOyBZPuFGEJj3cY2xi7V90Vl6x8bktP5S_eEbv9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