Bug 62240 - A using-declaration within a class can publish a public base of a private base.
Summary: A using-declaration within a class can publish a public base of a private base.
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.9.1
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
: 113286 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-08-23 14:27 UTC by Rohan Lean
Modified: 2024-01-09 14:37 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-07-27 00:00:00


Attachments
small testcase (90 bytes, text/plain)
2014-08-23 14:27 UTC, Rohan Lean
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rohan Lean 2014-08-23 14:27:07 UTC
Created attachment 33384 [details]
small testcase

Suppose that three classes are related by inheritance (B ---> A : B inherits from A) as follows:

  C ---private--> B ---public--> A

Then C can publish A via

  using B::A;

I think that the correct behaviour is to reject such a program.
Comment 1 Jonathan Wakely 2014-08-26 11:15:23 UTC
Agreed, the attached code (repeated below) should be rejected.


class A {};

class B : public A {};

class C : B
{
public:
  using B::A;
};

int main()
{
  A *p = new C;
}
Comment 2 Andrew Pinski 2024-01-09 04:09:09 UTC
*** Bug 113286 has been marked as a duplicate of this bug. ***