[Issue 19334] New: Derived class can access private members if class have a package member variable.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 25 22:48:57 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19334

          Issue ID: 19334
           Summary: Derived class can access private members if class have
                    a package member variable.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: alexanderheistermann at gmail.com

import std.stdio;
class A
{
    package int x;
    private int y;
}

class B : A
{
};

void main()
{
    B b = new B();
    b.y = 1; // Should be a compile error
    writeln(b.y);
    writeln(b.x);
}

Remove "package int x" and it works as intended.

--


More information about the Digitalmars-d-bugs mailing list