Created on 2008-11-18.00:00:00 last changed 178 months ago
Rationale (April, 2010):
This is a duplicate of issue 472.
Consider the following example:
struct B { void f(){} };
class N : protected B { };
struct P: N { friend int main(); };
int main() {
N n;
B& b = n; // R
b.f();
}
This code is rendered well-formed by bullet 3 of 11.8.3 [class.access.base] paragraph 4, which says that a base class B of N is accessible at R if
R occurs in a member or friend of a class P derived from N, and an invented public member of B would be a private or protected member of P
This provision circumvents the additional restrictions on access to protected members found in 11.8.5 [class.protected] — main() could not call B::f() directly because the reference is not via an object of the class through which access is obtained. What is the purpose of this rule?
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2011-04-10 00:00:00 | admin | set | messages: + msg3419 |
| 2011-04-10 00:00:00 | admin | set | status: open -> dup |
| 2008-11-18 00:00:00 | admin | create | |