<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141085>141085</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] OpenMP atomic compare fails when including <array> with `using namespace std;`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jhuber6
</td>
</tr>
</table>
<pre>
The following code causes a compilation failure only when `using namespace std;`. https://godbolt.org/z/adKe7x84c.
```c++
using namespace std;
#include <array>
template<typename T>
T atomicMin(T* acc, T value)
{
T old;
#pragma omp atomic capture compare
{
old = *acc;
if (value < *acc)
{
*acc = value;
}
}
return old;
}
```
```console
$ clang++ main.cpp -fopenmp
main.cpp:1:17: warning: using directive refers to implicitly-defined namespace 'std'
1 | using namespace std;
| ^
main.cpp:12:15: error: the statement for 'atomic compare capture' must be a compound statement of form '{v = x; cond-up-stmt}', ''{cond-up-stmt v = x;}', '{if(x == e) {x = d;} else {v = x;}}', '{r = x == e; if(r) {x = d;}}', or '{r = x == e; if(r) {x = d;} else {v = x;}}', where 'cond-update-stmt' can have one of the following forms: 'if(expr ordop x) {x = expr;}', 'if(x ordop expr) {x = expr;}', 'if(x == e) {x = d;}', or 'if(e == x) {x = d;}' where 'x', 'r', and 'v' are lvalue expressions with scalar type, 'expr', 'e', and 'd' are expressions with scalar type, and 'ordop' is one of '<' or '>'
12 | if (value < *acc)
| ~~~~~~^~~~~~
main.cpp:12:15: note: expect binary operator in conditional expression
12 | if (value < *acc)
| ~~~~~~^~~~~~
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVcuS6jgPfhqzUTUVnATDggXQzeavU_8seAHHUcCnHDtlO1xmMc8-pTg0l5k-PTOpdMdY0if5kyXJEPTBIq5YuWHl-0T28ej86uexr9DPJ5Wrr6v9EaFxxriztgdQrkZQsg8YQIJybaeNjNpZaKQ2vUdw1l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