Issue 61629
Summary CUDA/Clang-16/C++2b: std::isfinite is incorrectly resolved as isfinite from __clang_cuda_cmath.h
Labels new issue
Assignees
Reporter andrewcorrigan
    I have a minimal reproducer below which fails with:
- `clang-16`, `-std=c++2b`

But, compiles with:
- `clang-16`, `-std=c++20`
- `clang-15`, `-std=c++20`
- `clang-15`, `-std=c++2b`

Minimal reproducer:

```cpp
#include <cuda.h>
#include <cuda_runtime_api.h>

#include <numeric>

int main(int argc, char** argv)
{
    auto test = [&](auto x)
    {
        return std::isfinite(x);
    };

 test(-1.0f);

    return 0;
}
```

This compiles in C++20 mode with Clang-16, as well as both C++20 and C++2b mode with Clang-15:
```
% /install/llvm-16.0.0/bin/clang++ -std=c++2b -x cuda test.cpp 
% /install/llvm-15.0.0/bin/clang++ -std=c++2b -x cuda test.cpp 
% /install/llvm-15.0.0/bin/clang++ -std=c++20 -x cuda test.cpp 
```

However, the reproducer above fails to compile in C++2b mode with Clang-16
```
% /install/llvm-16.0.0/bin/clang++ -std=c++2b -x cuda test.cpp 
test.cpp:10:21: error: reference to __device__ function 'isfinite' in __host__ __device__ function
        return std::isfinite(x);
                    ^
test.cpp:13:9: note: called by 'main'
    test(-1.0f);
 ^
/install/llvm-16.0.0/lib/clang/16/include/__clang_cuda_cmath.h:103:17: note: 'isfinite' declared here
__DEVICE__ bool isfinite(float __x) { return ::__finitef(__x); }
                ^
test.cpp:10:21: error: reference to __device__ function 'isfinite' in __host__ __device__ function
        return std::isfinite(x);
 ^
test.cpp:14:9: note: called by 'main'
    test(-2.0);
 ^
/install/llvm-16.0.0/lib/clang/16/include/__clang_cuda_cmath.h:107:17: note: 'isfinite' declared here
__DEVICE__ bool isfinite(double __x) { return ::__isfinited(__x); }
                ^
2 errors generated when compiling for host.
```



_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to