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

    <tr>
        <th>Summary</th>
        <td>
            CUDA device code does not support variadic functions
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            cuda,
            clang:frontend,
            backend:NVPTX
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

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

<pre>
    I was looking at atomics support on CUDA: https://godbolt.org/z/3WqPYxEve

```C++
#include <cuda/std/atomic>

__global__ void k1(cuda::std::atomic<int>& a) {
    a++;
}

__global__ void k2(cuda::std::atomic<int>* a) {
    a->load(cuda::std::memory_order_seq_cst);
}

// __global__ void k3(cuda::std::atomic<int>* a) {
//     a->load(cuda::std::memory_order_acq_rel);
// }

__global__ void k4(cuda::std::atomic<int>* a) {
    a->load(cuda::std::memory_order_relaxed);
}

int main() {}
```

fails on Clang with:

```
In file included from <source>:1:
In file included from /opt/compiler-explorer/cuda/11.3.1/include/cuda/std/atomic:42:
In file included from /opt/compiler-explorer/cuda/11.3.1/include/cuda/std/type_traits:24:
/opt/compiler-explorer/cuda/11.3.1/include/cuda/std/detail/libcxx/include/type_traits:520:12: error: CUDA device code does not support variadic functions
false_type __sfinae_test_impl(...);
           ^
/opt/compiler-explorer/cuda/11.3.1/include/cuda/std/detail/libcxx/include/type_traits:1059:69: error: CUDA device code does not support variadic functions
    template <class _Tp> _LIBCUDACXX_INLINE_VISIBILITY static __two __test(...);
                                                                    ^
/opt/compiler-explorer/cuda/11.3.1/include/cuda/std/detail/libcxx/include/type_traits:1171:5: error: CUDA device code does not support variadic functions
    __any(...);
    ^
/opt/compiler-explorer/cuda/11.3.1/include/cuda/std/detail/libcxx/include/type_traits:1848:16: error: CUDA device code does not support variadic functions
   static void __test(...);
               ^
/opt/compiler-explorer/cuda/11.3.1/include/cuda/std/detail/libcxx/include/type_traits:4332:16: error: CUDA device code does not support variadic functions
  static __nat __try_call(...);
               ^
5 errors generated when compiling for sm_86.
Compiler returned: 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVl1v4ygU_TX2C6qFwXaSBz-kaStZqqqRtjvbeULYkIQtMS7gNNlfv5c4aZqZTne2iqYWccDAvece7ge1EduyQs_cIW3Mo2oXiHtoZqUah1zfdcZ6ZFo0-_NqGtEpWnrfOehE5AbawojaaJ8Yu4DRP_Cjfz19-ba5XssIX0V4un8XeGiziFyGNnwlVLWN7oVEEZ01veCw33kB7wFARK9fS2FsoU3NNWNobZRAj2lExrttNEALO3edw-aZan0QQQoEkicoGu0VI3j4Hgk9gBldvauL_KKu6Vu6LmBKGy7elrGSK2O3zFghLXPyiTXOg4yfQRuYRz8gpB9EuJf3f4Hy5olZqU-ADpL-i8rsN1EJ6PhGineoBE1oxVULwg6aXhYcXPb1-jlX2u2iQXOIlGfll0HvW54-DKsWzZWWaO_nAs2tWQVvd6a3jQxm0mn6IuMny8mN6cAjbhqz6mDaXshNp42VNnwbwiZNE5pAPNzstx5nTgNqmpHfoM1vO8m85cqHVEGyI0lnEC6kh2OAjlZ1s9mcLDxVnBMc6A0WI2mtsaETEhkScq0aiRoDuUcY6VBr_Eu2W3OruFANmvdt45Vp3eH0tQPpoAKCz81Vy2EknWdq1QGecZIkr30NHZ8ov_4M-1OcA5xpMTkTAcEUL8FY7oeUrblziN134MeI3VaXQfTs4YFVd7fV3TX7Wv1RXVa31f035Dz3IJAx_2zCW4YU9w5jH34-i-p0FMI4PyPTjPF2-zZJn2XkOBuHv-J8Vu79YlcYftEtPsn4jFJyXuNfYqKFKxcYD4Wr4fr9THJCQD7gcGghW2khKAV6XsoWDXyEu9zcWORWbFwkw47Znilkpe9tK0PZROl3pSuWZVoUBU5zXBSxKKmY0AmPvfJalh8xOO6tLr-7OELp7OsEkAbu9frwd9FZ87dswqkq53rpoJOPsxTHyxKnPK0zPhIiHdUNrTEe0xTTucA8qwvCY81rqV0Z5XCzI8Mxw7VthsIoFGzQDiWu9bIVx5maN4_hA53eff1y_xAm8qtYlQQTkmIIa5qPsiKhhPNcZkRgSSY5xlGGJVwddBJQh_tvbMudAXW_cDCplfPuOAmJUi1aKXfgQD7v_dLYct0se8vX23hnbLmz9F9rzHo_">