I get errors when I try to compile a .cu file which has a templated class which friends a constructor of another templated class. I’ve tried to isolate the error below. When I compile this code in a .cu file:
template <typename>
class B;
template <typename T>
class A {
public:
A(const B<T>& b) {}
void foo(const B<T>& b) { }
};
template <typename S>
class B {
public:
template<typename T>
friend A<T>::A(const B<T>& b);
template<typename T>
friend void A<T>::foo(const B<T>& b);
};
I get the following error:
$ nvcc -c test.cu
test.cu(20): error: explicit type is missing ("int" assumed)
1 error detected in the compilation of "/tmp/tmpxft_00001e29_00000000-4_test.cpp1.ii".
It compiles fine when I put the exact same code in a .cpp file. I thought nvcc simply forwarded non-CUDA code to the configured C compiler, but apparently something else is happening here. I would be happy for any help with understanding this.
This certainly looks like an issue in the CUDA compiler. It would be helpful if you could file a bug against the compiler, since you already have a minimal repro case in hand. There is a link on the registered developer website for filing bugs. Thank you for your help, and sorry about the inconvenience.
It has been a while since I myself signed up as a registered developer, but from what I recall your application should go through within a few days, provided you filled in the requested information on the application form. Should you experience undue delay, feel free to drop me a line using a PM (personal message) via this forum. Thank you for your patience.