[LLVMbugs] [Bug 10595] New: Friend with templated function parameter ignored

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 5 15:23:51 PDT 2011


           Summary: Friend with templated function parameter ignored
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: klimek at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

In the example code:
template<typename T> class X {
  friend int operator<<(int, const X<T>&) {
    return 42;

struct Y {};
int operator<<(int, const Y&);

void f(const X<double>& x1) {
  42 << x1;

  X<double> x2;
  42 << x2;

$ clang -c t.cc 
t.cc:13:6: error: invalid operands to binary expression ('int' and 'const
  42 << x1;
  ~~ ^  ~~
1 error generated. 

Both cases are accepted by gcc, and the case with 2 overloads is accepted by
clang, too:
$ clang -DSECOND_OVERLOAD -c t.cc 
$ g++ -c t.cc
$ g++ -DSECOND_OVERLOAD -c t.cc

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list