Issue |
127466
|
Summary |
clang OpenMP atomic capture compare: Bad diagnostic if overloaded `operator<` is declared (but not used)
|
Labels |
clang
|
Assignees |
|
Reporter |
q-p
|
The following code, reduced from the [alpaka framework for parallel acceleration](https://github.com/alpaka-group/alpaka) causes an error that -- as far as I can tell -- should not cause one (since the questionable `operator<` should never be used).
Removing the `operator<` overloaded causes the code to compile.
It feels like the diagnostic is emitted too early: Even if the call to `atomicOp` is commented out, then the template should not instantiated and no diagnostic shown, but it still causes a failure.. But I'm not a language lawyer.
```cpp
#define ERROR
#ifdef ERROR
class badouble { };
bool operator < ( double coval, const badouble& v ) ;
#endif
template<class T>
static auto atomicOp(T* const addr, T value) -> T
{
T old;
auto& ref(*addr);
// atomically update ref, but capture the original value in old
# pragma omp atomic capture compare
{
old = ref;
// Do not remove the curly brackets of the if body else
// icpx 2024.0 is not able to compile the atomics.
if(value < ref)
{
ref = value;
}
}
return old;
}
int main()
{
int i = 0, j = 1;
atomicOp(&i, j);
}
```
https://godbolt.org/z/9WsEfEbnG
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs