Bug 10170 – __traits(compiles,b.x)) incorrectly allows to access private members

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-25T22:08:00Z
Last change time
2017-01-16T15:07:34Z
Assigned to
nobody
Creator
thelastmammoth

Comments

Comment #0 by thelastmammoth — 2013-05-25T22:08:20Z
b.d: struct B{ private int x; private void foo1(); } a.d: import b; void main(){ auto b=B.init; static assert(__traits(compiles,b.x)); //why passes? static assert(__traits(compiles,b.foo1)); //why passes? static assert(!__traits(compiles,b.foo1())); //ok static assert(!__traits(compiles,b.x++)); //ok }