Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example in [class.protected] needs to be updated #527

Closed
timsong-cpp opened this issue Jul 21, 2015 · 1 comment
Closed

Example in [class.protected] needs to be updated #527

timsong-cpp opened this issue Jul 21, 2015 · 1 comment

Comments

@timsong-cpp
Copy link
Contributor

After CWG 1873, derived class friends have no access to base class protected members. The example in [class.protected], however, still labels such accesses as OK:

class B {
protected:
  int i;
  static int j;
};
class D1 : public B {
};
class D2 : public B {
  friend void fr(B*,D1*,D2*);
  void mem(B*,D1*);
};
void fr(B* pb, D1* p1, D2* p2) {
  // snip
  B::j = 5; // OK (because refers to static member) 
  D2::j = 6; // OK (because refers to static member)
}

The line B::j = 5; should be marked ill-formed instead.

@hubert-reinterpretcast
Copy link
Contributor

It seems

p2->B::i = 4;

is suspect too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants