[LLVMbugs] [Bug 8675] New: protected member access check should only apply to functions or data members

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 23 14:13:28 PST 2010


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: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


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.



More information about the llvm-bugs mailing list