public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60829] New: Illegal access to private base of public base granted.
@ 2014-04-12  0:25 arm.nahm at gmx dot de
  2014-04-12  0:27 ` [Bug c++/60829] " arm.nahm at gmx dot de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: arm.nahm at gmx dot de @ 2014-04-12  0:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

            Bug ID: 60829
           Summary: Illegal access to private base of public base granted.
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arm.nahm at gmx dot de

struct A{};
class B: A {};
struct C: A {};
struct D: B, C {
    D() { B::a = 0; }
};

The above code compiles in g++, even though the standard does not allow D
access to any member of the private base class A of public base class B.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/60829] Illegal access to private base of public base granted.
  2014-04-12  0:25 [Bug c++/60829] New: Illegal access to private base of public base granted arm.nahm at gmx dot de
@ 2014-04-12  0:27 ` arm.nahm at gmx dot de
  2014-04-12  6:16 ` glisse at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: arm.nahm at gmx dot de @ 2014-04-12  0:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

--- Comment #1 from arm.nahm at gmx dot de ---
First reported on StackOverflow:
http://stackoverflow.com/questions/23024091/multiple-inheritance-makes-private-member-accessible


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/60829] Illegal access to private base of public base granted.
  2014-04-12  0:25 [Bug c++/60829] New: Illegal access to private base of public base granted arm.nahm at gmx dot de
  2014-04-12  0:27 ` [Bug c++/60829] " arm.nahm at gmx dot de
@ 2014-04-12  6:16 ` glisse at gcc dot gnu.org
  2014-04-12  6:35 ` trippels at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-04-12  6:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to arm.nahm from comment #0)
> The above code compiles in g++,

No it doesn't. Please make sure to copy-paste directly from a file you have
tested.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/60829] Illegal access to private base of public base granted.
  2014-04-12  0:25 [Bug c++/60829] New: Illegal access to private base of public base granted arm.nahm at gmx dot de
  2014-04-12  0:27 ` [Bug c++/60829] " arm.nahm at gmx dot de
  2014-04-12  6:16 ` glisse at gcc dot gnu.org
@ 2014-04-12  6:35 ` trippels at gcc dot gnu.org
  2014-04-14 14:56 ` trippels at gcc dot gnu.org
  2014-06-12 13:53 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-04-12  6:35 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-12
                 CC|                            |trippels at gcc dot gnu.org
   Target Milestone|---                         |4.7.5
     Ever confirmed|0                           |1
      Known to fail|                            |4.7.3, 4.8.3, 4.9.0

--- Comment #3 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
markus@x4 /tmp % cat test.ii
class A
{
public:
  int a;
};

class B : private A
{
};

class C : public A
{
};

class D : public B, public C
{
  D () { B::a = 0; }
};

markus@x4 /tmp % g++ -c test.ii
markus@x4 /tmp % clang++ -c test.ii
test.ii:17:13: error: cannot cast 'B' to its private base class 'A'
  D () { B::a = 0; }
            ^
test.ii:7:11: note: declared private here
class B : private A
          ^~~~~~~~~
test.ii:17:13: error: 'a' is a private member of 'A'
  D () { B::a = 0; }
            ^
test.ii:7:11: note: constrained by private inheritance here
class B : private A
          ^~~~~~~~~
test.ii:4:7: note: member is declared here
  int a;
      ^
2 errors generated.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/60829] Illegal access to private base of public base granted.
  2014-04-12  0:25 [Bug c++/60829] New: Illegal access to private base of public base granted arm.nahm at gmx dot de
                   ` (2 preceding siblings ...)
  2014-04-12  6:35 ` trippels at gcc dot gnu.org
@ 2014-04-14 14:56 ` trippels at gcc dot gnu.org
  2014-06-12 13:53 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: trippels at gcc dot gnu.org @ 2014-04-14 14:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #4 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
EDG also rejects the code:

test.ii(17): error #308: member "A::a" (declared at line 4) is inaccessible
    D () { B::a = 0; }
              ^


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/60829] Illegal access to private base of public base granted.
  2014-04-12  0:25 [Bug c++/60829] New: Illegal access to private base of public base granted arm.nahm at gmx dot de
                   ` (3 preceding siblings ...)
  2014-04-14 14:56 ` trippels at gcc dot gnu.org
@ 2014-06-12 13:53 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.5                       |---

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Unsetting target milestone of open non-regression bug from version of branch
being closed.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-12 13:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-12  0:25 [Bug c++/60829] New: Illegal access to private base of public base granted arm.nahm at gmx dot de
2014-04-12  0:27 ` [Bug c++/60829] " arm.nahm at gmx dot de
2014-04-12  6:16 ` glisse at gcc dot gnu.org
2014-04-12  6:35 ` trippels at gcc dot gnu.org
2014-04-14 14:56 ` trippels at gcc dot gnu.org
2014-06-12 13:53 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).