nvcc compilation bug

Here is code that compiles with gcc 4.9.3, but not with nvcc:

//////////// file.cu ////////////////////////
class A
  template< typename T >
  using IoRefrType = const T&;

struct B;

template< class RWD >
#if 1
  bool copy( RWD& rwd, typename RWD::template IoRefrType< B > var );
  bool copy( RWD& rwd, const B& var );

extern template
 bool copy( A& wd, const B& var );

The command lines are
gcc-4.9.3 -x c++ -std=c++11 -c file.cu
nvcc --compiler-bindir gcc-4.9.3 -std=c++11 -c file.cu

If you change #if 1 to #if 0 at line 12, the compilation succeeds for nvcc, too.

Sorry, I forgot to say what the error message from nvcc is:

file.cu(18): error: no instance of function template “copy” matches the specified type

It seems that, the IoRefrType template is confusing nvcc, even though the straight C++ code should be passed directly to gcc.

The splitting of host and device code isn’t as simple as you might think. From what I understand, all code is properly parsed by the EDG frontend, and at least in the past it was the case that the host code passed to the host compiler wasn’t simply a verbatim copy of the original source code, but functionally equivalent.

One limitation of that process is that not all gcc extensions may be properly modeled right away.In addition, C++11 support in nvcc may not be 100% yet (not sure). Are you using the latest CUDA tool chain and is gcc 4.9 officially supported by that CUDA version? If the answer to both is “yes”, consider filing a bug report with NVIDIA (reporting form is linked from the CUDA registered developer website).

Thanks for the info. I have submitted the bug.

The CUDA 7.5 installation did not accept gcc-5, but worked fine with gcc-4.9.3 . The samples run correctly.