<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69288>69288</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Compiling with clang cuda fails when using libstdc++'s <format> header
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rnburn
</td>
</tr>
</table>
<pre>
Take this program
```
// main.cc
#include <format> // remove the format include and everything will work
#include <iostream>
int main() {
std::cout << "hello, hello\n";
return 0;
}
```
If I compile with
```
clang++ -std=c++23 main.cc
```
Everything works fine.
But if I compile with
```
clang -x cu --cuda-gpu-arch=sm_70 --cuda-gpu-arch=sm_70 -std=c++23 -c main.cc
```
I get the error below.
I'm using a version of clang I compiled from trunk against gcc13's libstdc++.
```
clang++ --version
clang version 18.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/nixos/.nix-profile/bin
```
This is the flake I used to build clang:
https://github.com/rnburn/nix-flakes/blob/f5ac34af8b5901e0d4d02cf83330739afae4f75e/flake.nix
Error
```
In file included from main.cc:1:
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3528:36: error: non-virtual member function marked 'override' hides virtual member function
3528 | _M_on_chars(iterator __last) override
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3621:55: note: in instantiation of template class 'std::__format::_Formatting_scanner<std::__format::_Sink_iter<char>, char>' requested here
3621 | _Formatting_scanner<_Sink_iter<_CharT>, _CharT> __scanner(__ctx, __fmt);
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3652:24: note: in instantiation of function template specialization 'std::__format::__do_vformat_to<std::__format::_Sink_iter<char>, char, std::basic_format_context<std::__format::_Sink_iter<char>, char>>' requested here
3652 | { return __format::__do_vformat_to(std::move(__out), __fmt, __args); }
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3679:10: note: in instantiation of function template specialization 'std::vformat_to<std::__format::_Sink_iter<char>>' requested here
3679 | std::vformat_to(__buf.out(), __fmt, __args);
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3478:30: note: hidden overloaded virtual function 'std::__format::_Scanner<char>::_M_on_chars' declared here
3478 | constexpr virtual void _M_on_chars(iterator) { }
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3535:34: error: non-virtual member function marked 'override' hides virtual member function
3535 | _M_format_arg(size_t __id) override
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3509:30: note: hidden overloaded virtual function 'std::__format::_Scanner<char>::_M_format_arg' declared here
3509 | constexpr virtual void _M_format_arg(size_t __id) = 0;
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3528:36: error: non-virtual member function marked 'override' hides virtual member function
3528 | _M_on_chars(iterator __last) override
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3621:55: note: in instantiation of template class 'std::__format::_Formatting_scanner<std::__format::_Sink_iter<wchar_t>, wchar_t>' requested here
3621 | _Formatting_scanner<_Sink_iter<_CharT>, _CharT> __scanner(__ctx, __fmt);
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3658:24: note: in instantiation of function template specialization 'std::__format::__do_vformat_to<std::__format::_Sink_iter<wchar_t>, wchar_t, std::basic_format_context<std::__format::_Sink_iter<wchar_t>, wchar_t>>' requested here
3658 | { return __format::__do_vformat_to(std::move(__out), __fmt, __args); }
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3688:10: note: in instantiation of function template specialization 'std::vformat_to<std::__format::_Sink_iter<wchar_t>>' requested here
3688 | std::vformat_to(__buf.out(), __fmt, __args);
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3478:30: note: hidden overloaded virtual function 'std::__format::_Scanner<wchar_t>::_M_on_chars' declared here
3478 | constexpr virtual void _M_on_chars(iterator) { }
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3535:34: error: non-virtual member function marked 'override' hides virtual member function
3535 | _M_format_arg(size_t __id) override
| ^
/nix/store/mwz5ch896ykn5zyjdgzar0zc9f9phm69-gcc-13.1.0/lib64/gcc/x86_64-unknown-linux-gnu/13.1.0/../../../../include/c++/13.1.0/format:3509:30: note: hidden overloaded virtual function 'std::__format::_Scanner<wchar_t>::_M_format_arg' declared here
3509 | constexpr virtual void _M_format_arg(size_t __id) = 0;
| ^
4 errors generated when compiling for s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