llvm-project
llvm-project copied to clipboard
[Issue]: `#include <cmath>` fail to compile with c++23 when using hip
Problem Description
Since MSVC implements P0533R9 all math function from the standard library become constexpr when enabling C++23. Hip treats constexpr functions as implicitly as __host__ __device__ so when the compiler tries to inject the device math functions, it fails since you cant overload a __host__ __device__ with another __device__ function:
In file included from <built-in>:1:
In file included from C:\opt\rocm\lib\clang\20\include\__clang_hip_runtime_wrapper.h:142:
C:\opt\rocm\lib\clang\20\include\__clang_cuda_math_forward_declares.h:88:17: error: __device__ function 'isfinite' cannot overload __host__ __device__ function 'isfinite'
88 | __DEVICE__ bool isfinite(long double);
| ^
C:\BuildTools\VC\Tools\MSVC\14.43.34808\include\cmath:673:17: note: previous declaration is here
673 | _CLANG_BUILTIN1(isfinite)
| ^
Currently this only affects windows since MSVC is the only one that has implemented P0533R9, but when gcc does implement it, this will become a problem for linux as well.
Operating System
Windows
CPU
NR
GPU
NR
ROCm Version
6.4
ROCm Component
No response
Steps to Reproduce
No response
(Optional for Linux users) Output of /opt/rocm/bin/rocminfo --support
No response
Additional Information
No response