[llvm-bugs] [Bug 38882] New: name lookup in qualified friend declaration is extremely suspicious

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Sep 9 23:19:07 PDT 2018


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

            Bug ID: 38882
           Summary: name lookup in qualified friend declaration is
                    extremely suspicious
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Testcase:

using T = int;

namespace N {
  struct X {
    template<typename T> void f(T);
  };
  template<typename> struct Y {
    template<typename T> friend void X::f(T); // #1
    friend void X::f<>(Y); // #2
  };
}

Here, #1 resolves T as ::T, not as the template parameter. Strangely, we fail
to diagnose this, and instead silently befriend nothing in line #1.

In #2, Y resolves to N::Y, not to the injected-class-name of N::Y, and as a
result declaration #2 is rejected because Y is lacking its template arguments.

These results both seem extremely surprising. The standard's rules here are
highly unclear, but this cannot be the right behavior...

-- 
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/20180910/75e348ab/attachment.html>


More information about the llvm-bugs mailing list