<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69368>69368</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion fail at kmp_runtime.cpp for omp teams distribute parallel for if
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
fel-cab
</td>
</tr>
</table>
<pre>
The following code fails on an assert
```
int main() {
int a[2];
int attempt = 0;
#pragma omp parallel for
for (int i = 0; i < 2; i++) {
a[i] = 2;
}
#pragma omp teams distribute parallel for if(attempt >= 2)
for (int i = 0; i < 2; i++) {
a[i] = 1;
}
return 0;
}
```
As
```
Assertion failure at kmp_runtime.cpp(1149): this_thr->th.th_task_team == this_thr->th.th_team->t.t_task_team[this_thr->th.th_task_state].
OMP: Error #13: Assertion failure at kmp_runtime.cpp(1149).
OMP: Hint Please submit a bug report with this message, compile and run commands used, and machine configuration info including native compiler and operating system versions. Faster response will be obtained by including all program sources. For information on submitting this issue, please see https://github.com/llvm/llvm-project/issues/.
Aborted
```
When LLVM is built as:
```
cmake -G Ninja -S ${PROJROOT}/llvm-project/llvm -B ../ \
-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;clang-tools-extra;lld;openmp \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
```
but not if it is built as:
```
cmake -G Ninja -S ${PROJROOT}/llvm-project/llvm -B ../ \
-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;clang-tools-extra;lld;openmp \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=Release
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVl1zozYU_TX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