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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Assertion 'this->_M_is_engaged()' failed.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    With assertion-enabled flang-new, the following program causes an assertion failure.

Reproducer:
```f90
!$omp critical
!$omp do simd
!$omp end critical
end
```

Assertion:
```txt
/usr/bin/../lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13/optional:486: const _Tp &std::_Optional_base_impl<Fortran::parser::DoConstruct, std::_Optional_base<Fortran::parser::DoConstruct>>::_M_get() const [_Tp = Fortran::parser::DoConstruct, _Dp = std::_Optional_base<Fortran::parser::DoConstruct>]: Assertion 'this->_M_is_engaged()' failed.
```

Note: This is not an arm-specific problem.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVMFupDgQ_ZriYoGMwdAcOHSHcMtmtYq0R2RsA941NrJNkvn7EdA9GfVoRtGMVDJSqerxXPWemfdqNFLWQC9Am4itYbKu_j9mztk3H_VWfKn_VWFCzHvpgrImlob1Wgo0aGbG2Mg3IA8oTBINVmv7psyIFmdHx2bE2eqlR8x8tKOBKb06mQBuAJ-P8x-5OCtWLh1k1xQU-IihwtcMSYHkdl4QdyoozvR9Xljk1Szu09KIuxZpxN1fvmdzvnH9kUx4Dzf0dvUOSNsrA6RNEiCtVj2QduQcSMuY41ORx1qZ9T0ezQqkTbNb5d2hDNerkEBaDuSyx1Fsl40G05Cd81MB2Rlxa3xA3cuCgBQ-iI1idu6er4Vdz7zs1LxoyB5a64Jj5ihZmPPHeLNzYx82GLfysO3uJzCfRcge99gBnrpRBiAnINWVKtDLzjZr0Gf5dM1R_-e8aLPN7Ns-EZAyTMrHkD12T53ynTQjG6U4GAMpd3VKkfxCHX_ZIDfUl0l5pDwyNuwCd3PsF8nVoPim_17LOYlEnYkqq1gk67QklJ7KrMDRVAtRVHmeiyHv6cDK4YRxyqmgrCjEUPVVpGqCSY4rXOA0rwhOeiopYWmWVkVBeV9CjuXMlE60fp0T68ZIeb_KOsUlxTjSrJfa77YmZHcqELI53NVbQ9yvo4cca-WD_4AIKuj9LWj3DtoAvTwv0jz9DbT5nTlGq9P1FMLit_2QdvOHCtPaJ9zOm2X06-0TL87-JzcFtPtN_GaC4zKvNfkaAAD__4y1avM">