Consider the following minimal example:
template<class T, int>
struct A
{
A() = default;
A(int) : A() {}
};
int main()
{
return 0;
}
Compiling with “nvcc -std c+11 -o bug bug.cu” (and, as I am on Arch Linux, ccbin set to a vanilla gcc 4.9.3) returns the following error message:
bug.cu: In constructor ‘A<T, <anonymous> >::A(int)’:
bug.cu:5:18: error: ‘__T0’ was not declared in this scope
A(int) : A() {}
^
bug.cu:5:22: error: template argument 2 is invalid
A(int) : A() {}
^
bug.cu:5:24: error: expected ‘{’ before ‘(’ token
A(int) : A() {}
^
When looking at the preprocessed files nvcc transformed the struct to this:
template< class T, int >
struct A {
A() = default;
A(int) : ::A< T, __T0> () { }
};
__T0 is of course undefined and thus causes an error once gcc takes over.
I am posting this here as I am somehow not allowed to file a bug on the official bug tracker despite being an “approved” developer.
I am using CUDA Toolkit v7.0 and I am on the x86_64 platform.