Bug 21275 – Overload resolution bypasses private access

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-09-25T14:06:47Z
Last change time
2023-06-16T11:51:21Z
Keywords
pull
Assigned to
No Owner
Creator
60rntogo

Comments

Comment #0 by 60rntogo — 2020-09-25T14:06:47Z
If I define the following module: --- module foo; struct Foo { import std : writeln; private int _x; private ref int x() return { writeln("ref int"); return _x; } int x() const { writeln("int"); return _x; } } --- and in another module: --- void main() { import std : writeln; import foo : Foo; auto f = Foo(); f.x = 3; writeln(f); } --- then the program prints --- ref int Foo(3) --- so I have gained access to private method x and member _x.
Comment #1 by dlang-bot — 2020-09-29T06:06:24Z
@RazvanN7 created dlang/dmd pull request #11811 "Fix Issue 21275 - Overload resolution bypasses private access" fixing this issue: - Fix Issue 21275 - Overload resolution bypasses private access https://github.com/dlang/dmd/pull/11811
Comment #2 by dlang-bot — 2020-09-29T07:29:41Z
dlang/dmd pull request #11811 "Fix Issue 21275 - Overload resolution bypasses private access" was merged into master: - f6d1f7f87c1c090bd0009d90c3ea44ef0537fbab by RazvanN7: Fix Issue 21275 - Overload resolution bypasses private access https://github.com/dlang/dmd/pull/11811
Comment #3 by dlang-bot — 2023-06-16T11:51:21Z
dlang/dmd pull request #15319 "Make 'private function is not accessible' deprecation an error." was merged into master: - fd0ebb96e18d3fa54d53bfb71210da2ff9135463 by Mathis Beer: Make 'private function is not accessible' deprecation an error. Affects issue 21275, 23947. https://github.com/dlang/dmd/pull/15319