Problem compiling simple example with NVCC, Clang-9 and LLVM libc++

Cross-posted from StackOverflow:

I’m having some trouble compiling a simple test program with NVCC using Clang-9 as a host compiler and libc++ as the STL implementation.


  • Ubuntu 18.04-LTS
  • NVCC 11.0.194
  • Clang-9 installed from the LLVM APT packages
  • LLVM Libc+±9

I have the following test program,

#include <string>
#include <cstring>
#include <iostream>

std::string device_description() {
    int device_count = 0;
    cudaError err = cudaGetDeviceCount(&device_count);
    for ( int i = 0; i < device_count; ++i) {
        cudaDeviceProp props;
        err = cudaGetDeviceProperties(&props, i);
        if (!err) {
            return std::string(, std::strlen(;
    return "no device";

int main() {
    std::cout << device_description() << std::endl;
    return 0;

It compiles and runs successfully with NVCC and clang as follows:

nvcc --std c++17 -ccbin /usr/bin/clang++-9 -o test

However, if I attempt to compile with libc++

nvcc --std c++17 -forward-unknown-to-host-compiler -ccbin /usr/bin/clang++-9 -stdlib=libc++ -o test

I get the following output:

/usr/lib/llvm-9/bin/../include/c++/v1/type_traits(559): error: type name is not allowed

/usr/lib/llvm-9/bin/../include/c++/v1/type_traits(559): error: type name is not allowed

/usr/lib/llvm-9/bin/../include/c++/v1/type_traits(559): error: identifier "__is_same" is undefined


21 errors detected in the compilation of "".

Am I missing something?

Hi @andrew5, I’m experiencing the exact same errors - “type name is not allowed” and “identifier “__is_same” is undefined”. Did you solve it eventually? Otherwise, do you have any insights?