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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] Incorrect execution of Fujitsu test 1052_0201
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          eugeneepshteyn
      </td>
    </tr>
</table>

<pre>
    Test source: https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/1052/1052_0201.f90

Sometimes compiling/running this test results in a segmentation faul:
```
$ flang -fopenmp 1052_0201.f90 && ./a.out
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
1052_0201.f90:30:9: warning: OpenMP directive MASTER has been deprecated, please use MASKED instead.
 !$omp master
          ^^^^^^
Segmentation fault (core dumped)
```

Sometimes it's incorrect output:
```
$ flang -fopenmp 1052_0201.f90 && ./a.out
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
1052_0201.f90:30:9: warning: OpenMP directive MASTER has been deprecated, please use MASKED instead.
    !$omp master
          ^^^^^^
 NG 1
 NG 3
 NG 4
 NG 5
 NG 6
 NG 7
 NG 8
 NG 9
 NG 10
 NG 11
...
```

flang version:
```
$ flang --version
flang version 21.0.0git (https://github.com/eugeneepshteyn/llvm-project.git cf348e886d0b30a4bf3e810efc00b2da0f7a4322)
Target: x86_64-unknown-linux-gnu
Thread model: posix
...
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVU2PpDYQ_TXVlxLImI-GAwc2M0RRtEmUGSnHlcEF7Q3YyB-zs_8-MvRMdnqTkXJPC_WzkO2qeq_qIZxTsyZqofwA5d1JBH8xtqUwkyba3MXTV30ajPzaPpLz6EywI0He4cX7zUHeAe-B97PylzCko1mB91P4rLwLwPvRrJtayCaenE9cUJ6A98NiBuD9KpQG3vfGeiviKmMlv8InxlmWTg0D1gHrHsxKXq3k8LhR6Rl4b4PWSs_oL8phjICWXFi8Q6VRoKN5Je2FV0bjJMISs2UdVOz6sA54gdMi9IzJZDbS64ZvoiPwCniFKfBepCZ4YN2-P-FZJOGLsDGDuPx1I_3xN3Rh24z1MYPjYuXQebUsSM8bWbVntCCUH5I_vn2TmC3mCeUdsO4tA3mXx7_mnwNKZWn06onwY_fweP87XoTDgUijpM3SKDxJ4D_gtpBwhMHtG3--v0OlnSchU2AdAs-AF2bdcBXOk43vXn9Q3t8-rHu4Zdcj8Ho0llCGdYtBm1u2vxVSeeDnqNRobKwATfBb8P9r9K8aRSX-s0z4y4-YXTG_YnHF8orVFc9XrK_YvJxnL4t4U5qm3-t68PhE1kWC3tMwedl0cwh5lrKUzWrvo3fc5a03Ae-X5WlNNms-0-jTeH6c8qKmuq4kG3ImimHKqc4YTSNjA5eCTWdR5JwfHfoo7Eyx7_C5rj5VRRL0n9p80cmidHhOZh3iposlIXE1kqKN4Gacev6ejJNsc9nkjThRm52LhlVVXp5Pl3YkNk2VqMXU5NUwSjGUU36epJRNlbFJnlTLGS9ZxYqsKcrynJ7rmg0VL6SsJKsYQcFoFWpJY7mpsfNJOReozQpe5_VpEQMtbrdxzndiIe-OcQHOo7XbdidqCLODgi3Keff3XV75Zf8IHEfLOyg_HM0L5R3-9Dqk9Exj2EfeTNgfPn9Y7-s8nIJd2nf0izFvVAPe78W46P5HPU8t_ysAAP__UWACwQ">