[llvm-bugs] [Bug 46036] New: Clang prohibits base class friend member access

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 22 05:23:54 PDT 2020


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

            Bug ID: 46036
           Summary: Clang prohibits base class friend member access
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dragondreamer at live.com
                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

Clang (at least trunk, 10.0, 9.0, 8.0, 7.0) rejects to compile the following
code:

// ===================================
#include <iostream>

struct test_base
{
protected:
    static constexpr int value = 123;
};

template<typename Base>
struct ignored_friend_declaration
{
    static void bug()
    {
        std::cout << Base::value;
    }
};

struct test_child : test_base
{
    using ignored_friend_declaration_t = ignored_friend_declaration<test_base>;
    friend ignored_friend_declaration_t;

    static void test()
    {
        ignored_friend_declaration_t::bug();
    }
};

int main()
{
    test_child::test();
}
// ===================================

With the following error: <source>:14:28: error: 'value' is a protected member
of 'test_base'.

G++ and MSVC successfully compile this code.

It seems that Clang ignores the friend declaration of the "test_child" class,
which is inherited from "test_base".

-- 
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/20200522/fcf73d63/attachment.html>


More information about the llvm-bugs mailing list