nvcc 5.5 bug parser: unable to declare a "friend bool operator< <>"

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.

Sorry for the inconvenience. It seems like things are moving in a vicious circle somehow. Please file a bug report using the form linked from the registered developer site and attach your repro case, so the compiler team can take a closer look at this. If you still know the bug number from the time you reported the previous issue I would recommend mentioning that. Thank you for your help.

Hi,

I’ve just submitted this bug.

Thank you.