NVCC preprocessor bug causes compilation failure

I’m trying to use abseil (https://abseil.io/) in a project that also uses CUDA 9.2. Including #include <absl/container/flat_hash_map.h> to any .cu causes compilation to fail with:

error: ‘__T0’ was not declared in this scope 
using Base = typename node_handle::node_handle_base;

the code around doesn’t show any __T0 parameter:

template <typename Policy, typename Alloc, typename = void>
class node_handle : public node_handle_base<Policy, Alloc> {
  using Base = typename node_handle::node_handle_base;

however compiling with nvcc -Xcompiler -E reveals that nvcc has inserted a __T0 parameter:

template< class Policy, class Alloc, class = void>
class node_handle : public node_handle_base< Policy, Alloc> {
  using Base = typename container_internal::node_handle< Policy, Alloc, __T0> ::node_handle_base;

it goes without saying but compiling with gcc/clang doesn’t give any error. I don’t need abseil in my kernels so I could split my source code to avoid including the flat_hash_map from any .cu files, however I’m looking for suggestions on a real solution. My full nvcc command when building looks like this (generated by cmake, line breaks inserted by me for readability):

-Xcompiler -fvisibility=hidden,-fno-rtti 
-x cu 
-dc /home/goodbyte/projects/groda/src/plugins/surface/mirror/mirror.cu 
-o CMakeFiles/surface_mirror.dir/mirror.cu.o

I noticed that when I name the anonymous template parameter it compiles, e.g. by changing

template< class Policy, class Alloc, class = void>


template< class Policy, class Alloc, class A = void>

however I just get into other problems in same file where this:

template <class T, RequiresInsertable<T> = 0,
            typename std::enable_if<IsDecomposable<T>::value, int>::type = 0,
            T* = nullptr>
  std::pair<iterator, bool> insert(T&& value) {
    return emplace(std::forward<T>(value));

gets mangled into (reindented by me)

template< class T, RequiresInsertable< T> = 0, 
          typename std::enable_if< container_internal::IsDecomposable< void, hash_policy_traits< Policy> , Hash, Eq, T...> ::value, int> ::type = 0,
          T * = (T *)nullptr>
std::pair< iterator, bool> insert(T &&value) {
  return emplace(std::forward< T> (value));

try cuda 10

I just upgraded to CUDA 10, I still get exactly the same error :(

Can you provide a short complete example, demonstrating the issue, pasted right here in this thread? I’d prefer not to spend time wading through the abseil website to figure out how to get access to the header file, then parse a complicated makefile.

What you’re describing sounds fairly simple to set up.

Show me how to get the exact header file.

Give me the code that includes that header file to demonstrate the issue.

Give me the single compile command line to demonstrate the issue.

Alternatively, you’re welcome to file a bug at developer.nvidia.com

Thank you. I’ve put up an example at https://github.com/erikman/cuda-abseil it uses the full abseil library (pulled in via git submodules). There are too many links between different header files to easily to pull out a minimal example with just one header file.

To see the preprocessed source you can use

nvcc   -Iabseil -x cu -c -Xcompiler -E example.cu -o example.S

The first compilation error with the inserted template parameter is at line 123545 in the preprocessed source, search for

549 “abseil/absl/container/internal/raw_hash_set.h”