http://llvm.org/bugs/show_bug.cgi?id=8675

           Summary: protected member access check should only apply to
                    functions or data members
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


11.5 is such a great passage. It reads that "When a friend or a member function
of a derived class references a protected nonstatic member function or
protected nonstatic data member of a base class, an access check applies in
addition..."

Consider this testcase:

  class Base {
    protected:
    struct Foo { int i; };
  };

  struct Derived : public Base {
    friend class Friend;
  };

  struct Friend {
    void f() {
      Base::Foo foo = { 42 };
    }
  };

which is accepted by gcc but rejected by clang:

b3224358.cc:12:11: error: 'Foo' is a protected member of 'Base'
    Base::Foo foo = { 42 };
          ^
b3224358.cc:3:10: note: declared protected here
  struct Foo { int i; };
         ^
1 error generated.

In this case, the member is neither a nonstatic function nor a data member of a
base class, so the additional access specified in 11.5 should not apply.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to