-----------
module static_a;
import static_b;
void main() {
Test.counter=5;
}
-----------
module static_b;
class Test {
private:
static int counter=0;
}
Comment #1 by tomas — 2008-05-04T21:10:29Z
Adding the following line to expressions.c(VarExp::semantic) catches it:
// check access to VarDeclaration
accessCheck(loc, sc, NULL, var);
Comment #2 by tomas — 2008-05-06T22:48:39Z
I've compiled several tango modules with this fix in place and it has already exposed two bugs in tango and no false positives so far.
;)
Comment #3 by tomas — 2008-09-27T09:14:36Z
This fix has been in place in LLVMDC for a long time, the change is trivial, it's not yet produced any false positives, just found bugs ... could we please get this into DMD ?
Comment #4 by matti.niemenmaa+dbugzilla — 2008-09-27T11:15:07Z
Severity doesn't mean how easy an issue is to fix. I set it back to "normal" and added the "patch" keyword instead.
As an aside, does that patch also fix Issue 313? What about Issue 314?
Comment #5 by kamm-removethis — 2008-09-30T00:37:41Z
(In reply to comment #4)
> As an aside, does that patch also fix Issue 313? What about Issue 314?
No it doesn't, but 314 has a patch that could be adapted to fix both. I didn't apply it to LLVMDC since it'd break compatibility to DMD in a fairly major way. On the other hand, it *is* a bug; I'll look at it again.
Comment #6 by tomas — 2008-12-10T06:58:17Z
The fix I proposed is indeed broken (or accessCheck is), it causes protection problems when instantiating imported templates passing private variables as alias template parameters. I've removed it from LDC again. Removing patch keyword
Comment #7 by k.hara.pg — 2012-12-18T21:38:56Z
Partially fixed in issue 5385.
Comment #8 by andrej.mitrovich — 2012-12-19T02:25:48Z
(In reply to comment #7)
> Partially fixed in issue 5385.
Which testcases did I miss?
Comment #9 by hsteoh — 2014-07-19T01:25:16Z
Seems to have been fixed in git HEAD (D2): the compiler now says, for the original test case:
static_a.d(4): Error: class static_b.Test member counter is not accessible
Removing D2 tag.
Comment #10 by bugzilla — 2016-10-14T03:13:12Z
As this is fixed in D2, and broke existing code while doing it. Any use of D1 is for legacy compatibility and not breaking things, so there seems no reason to fix this for D1.