Bug 11234 – Address of private method from another module can be taken

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-12T12:20:03Z
Last change time
2024-12-13T18:12:37Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
rswhite4
Moved to GitHub: dmd#18694 →

Comments

Comment #0 by rswhite4 — 2013-10-12T12:20:03Z
A.d: ---- import B; class Foo { public: void call(Bar b) { void delegate(int) dg = &b.test; dg(42); } } void main() { Bar b = new Bar(); Foo f = new Foo(); f.call(b); } ---- B.d: ---- import std.stdio; class Bar { private: void test(int id) { writeln("Bar called with ", id); } } ---- Output: Bar called with 42 But should be rejected.
Comment #1 by andrej.mitrovich — 2013-10-12T12:23:34Z
Reduced a little bit: ----- module a; import b; void main() { auto s = S(); auto f = &s.f; // no error f(); // no error auto sf = &S.sf; // error } ----- ----- module b; struct S { private void f() { } private static void sf() { } } -----
Comment #2 by rswhite4 — 2013-10-12T12:29:08Z
I'm unsure, but maybe we should also classify this as major because it breaks the protection?
Comment #3 by robert.schadek — 2024-12-13T18:12:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18694 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB