[LLVMbugs] [Bug 7308] New: Clang doesn't consider conversion function template friends.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 5 07:19:59 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7308

           Summary: Clang doesn't consider conversion function template
                    friends.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: schaub-johannes at web.de
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Clang doesn't like this, saying that "u.m_a" is private. 

template <class T>
class A
{
public:
    template <class U>
    operator A<U>() {
        A<U> u;
        u.m_a = m_a; 
        return u;
    }

    template <class U> template<class V>
    friend A<U>::operator A<V>();
private:
    int m_a;
};

void f() {
   A<int> a = A<double>();
}

There seems to be poor support for such friends. Comeau fails with an ICE
assertion failure and GCC doesn't like it either. 

I believe this program is correct according to the Standard (however the
Standard says that you can define function template friends in the friend
declaration - this can't be true for member function templates. Sounds like the
text treats "member function template" and "member template" as being mutually
exclusive?). 

If this is indeed not valid, it would seem to be a good thing to reject this
straight away when the template is parsed.

-- 
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