[llvm-bugs] [Bug 51134] New: Can't access private static variable template from a friend class, in the type of a static variable template

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 19 04:53:29 PDT 2021


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

            Bug ID: 51134
           Summary: Can't access private static variable template from a
                    friend class, in the type of a static variable
                    template
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: blckcat at inbox.ru
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Example code:
```
class A
{
    friend struct B;

    template <typename>
    static constexpr int x = 42;
};

struct B
{
    template <typename U>
    static constexpr decltype(A::template x<U>) y = 43;
};

int main()
{
    (void)B::y<int>;
}
```
This gives me `error: 'x' is a private member of 'A'`.

Removing template-ness from either variable fixes the issue. Accessing `x` from
the initializer of `y` (rather than from its type) also works.

-- 
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/20210719/ad75e5a5/attachment.html>


More information about the llvm-bugs mailing list