<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63687>63687</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Worse diagnostics on missing std:: with cmath functions in HIP than C++
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            cuda,
            clang:headers
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            Artem-B,
            yxsamliu,
            jhuber6
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          arsenm
      </td>
    </tr>
</table>

<pre>
    Consider this testcase which compiles if including <math.h>, and doesn't if using cmath. The error is much more intelligible with standard C++, CUDA and OpenMP. The HIP errors includes a lot of implementation details which make it appear like something is wrong there, rather than you just missed using std::

```
#include <cmath>

int main() {
    float x = 0.0f;
    bool test = isinf(x);

    return 0;
}

```

```
$ clang++ -x hip  isinf.cpp 
isinf.cpp:6:17: error: no matching function for call to 'isinf'
    6 |     bool test = isinf(x);
      | ^~~~~
/usr/lib/llvm-17/lib/clang/17/include/__clang_hip_cmath.h:512:23: note: candidate template ignored: substitution failure [with __T = float]: no type named 'type' in '__hip_enable_if<false, bool>'
  512 | __HIP_OVERLOAD1(bool, isinf)
      | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/lib/llvm-17/lib/clang/17/include/__clang_hip_cmath.h:452:7: note: expanded from macro '__HIP_OVERLOAD1'
  452 |       typename __hip_enable_if<__hip::is_integral<__T>::value, __retty>::type  \
      | ~~~~
  453 |       __fn(__T __x) { \
      | ^
/usr/lib/llvm-17/lib/clang/17/include/__clang_hip_cmath.h:96:31: note: candidate function not viable: call to __device__ function from __host__ function
   96 | __DEVICE__ __CONSTEXPR__ bool isinf(float __x) { return ::__isinff(__x); }
      | ^
/usr/lib/llvm-17/lib/clang/17/include/__clang_hip_cmath.h:97:31: note: candidate function not viable: call to __device__ function from __host__ function
   97 | __DEVICE__ __CONSTEXPR__ bool isinf(double __x) { return ::__isinf(__x); }
      |                               ^
1 error generated when compiling for gfx906.

```

Compare to:
```
$ clang++ -x c++  isinf.cpp 
isinf.cpp:6:17: error: use of undeclared identifier 'isinf'
    6 |     bool test = isinf(x);
      | ^
1 error generated.

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8ll9v2zYXxj8NfXNQw6Isy77whSPbaIH3XYIu63ZHUOKRxZYiBZJKnJt89oGUrHhd1qxAO0Ow-U80n9_hQx7unDxpxC3JbgilO-uxfRdKhBaE0qez462S_dTwuelLtKtQz_Yz3vvG2C23DnU7K4142hZGOynQgm-kA4_OV9whPDayaqAybScVOpA1SF2pXkh9ApIWLffNvCHpgdACuBYgDDpNaO7D0N6FYVUcBPcNAlprLEgHbV810BqLILVHpeRJlgrhUfoGnOdacCugIPQmPgUUv-13cf7bDvX_74bZ3n-4G2Z046LQAQdlPJgaZNspbFF77qXRINBzqdyop-VfEKQH3nXILSj5BcGZFn0TFiwdPFqjT-AbtBj-3vJQBN9wDU-mh8-989BK51CMIp0XJN2FZ7Eni8v3ajE-Q5Wm4zoDuoglkLt6QWoPLZea0DWhGyD5zdAOAFArwz2cgaR7WMwXNUmvOktjVAxa7JZO6prQ9ZnQzTTsZbBF31sNi5eufP-tZb-uZQmV4vo0xAjenaGRHQx_Pa-6DkZFlzpJdyuS7pKcpLshaqGgDbTcVxF73esqxqo2FiquFHgDhOajmvxFwApIXsC_1B3HxRdIdnh-fn6-CDj2zhJ6VLIM3-qhfZfkU33UdoxNY9QIPTIWO1gjO1ZdNv8uSyhJdzQdFHkMvxXXQgruETy2nQoFedLGYtgn4PrSeen7QS-XqrcIJLuJBmDsPsqJESfZfgTlnzoEzVsUgUqoEZqD1KHG4opQ81IhkzVJi5orF_duQBQNOgHMEhp5MPb-wx27_XT4-L_b3T4hdB3H0uICcvM1wedXPyPXnwB2mQWw-TVXPHdcCxRQW9NCyytrBgBfaZnULjM6bReIEAND-Dux2DKYWDoWzqWT5Sp23AeAseeBqz5iZcyi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