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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to