[llvm-bugs] [Bug 30859] New: Bogus access error when befriending a member function template specialization

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 31 15:20:27 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30859

            Bug ID: 30859
           Summary: Bogus access error when befriending a member function
                    template specialization
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rs2740 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

>From http://stackoverflow.com/q/40350327/2756719. Repro:

struct X
{
    template <class T> static void f() { g<T>(); }
private:
    template <class T> static void g() {};
};

struct Y
{
    friend void X::f<Y>(); /// #1
};

int main() 
{
    X::f<Y>();
}

results in the following obviously bogus error:

prog.cc:3:42: error: 'g' is a private member of 'X'
    template <class T> static void f() { g<T>(); }
                                         ^~~~
prog.cc:15:8: note: in instantiation of function template specialization
'X::f<Y>' requested here
    X::f<Y>();
       ^
prog.cc:5:36: note: declared private here
    template <class T> static void g() {};
                                   ^
1 error generated.

Commenting out line #1 makes the code compile, suggesting that somehow the
friend declaration caused the access checking to be done in the wrong context.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161031/6e32e69c/attachment.html>


More information about the llvm-bugs mailing list