Hi,
the last year, I posted a topic called ‘nvcc 4.0 : unable to declare a “friend std::ostream& operator<< <>”’ : nvcc 4.0 : unable to declare a "friend std::ostream& operator<< <>" meth - CUDA Programming and Performance - NVIDIA Developer Forums.
In this topic, I explained I was unable to compile some specialized templated functions due to a NVCC 4.0 bug. This bug has been corrected with NVCC 4.1.
But, yesterday, I have installed the CUDA 5.5 toolkit and this bug seems to come back again… partially. In fact, the declaration “operator << <>” compiles fine but the declaration “operator< <>” fails.
Simple example :
#include <iostream>
template<typename T>
class Test;
template<typename T>
std::ostream& operator<< (std::ostream& out, const Test<T>& t);
template<typename T>
bool operator< (const Test<T>& t1, const Test<T>& t2);
template<typename T>
class Test
{
// CUDA 5.0 = OK
// CUDA 5.5 = OK
friend std::ostream& operator<< <>(std::ostream& out, const Test<T>& t);
// CUDA 5.0 = OK
// CUDA 5.5 = ERROR
friend bool operator< <>(const Test<T>& t1, const Test<T>& t2);
};
int main(int argc, char** argv)
{
return 0;
}
This example compiles fine with NVCC 5.0.
But NVCC 5.5 returns the following error:
test.cu:21:21: error: declaration of ‘operator<<’ as non-function
test.cu:21:21: error: expected ‘;’ at end of member declaration
test.cu:21:23: error: expected unqualified-id before ‘>’ token
I’m using :
Ubuntu 12.04
Cuda compilation tools, release 5.0, V0.2.1221
Cuda compilation tools, release 5.5, V5.5.0
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
This post is also related to bug in nvcc parser << < is not the same as <<< - CUDA Programming and Performance - NVIDIA Developer Forums.
Thanks.
M.D.