----------- module static_a; import static_b; void main() { Test.counter=5; } ----------- module static_b; class Test { private: static int counter=0; }
Adding the following line to expressions.c(VarExp::semantic) catches it: // check access to VarDeclaration accessCheck(loc, sc, NULL, var);
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. ;)
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 ?
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?
(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.
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
Partially fixed in issue 5385.
(In reply to comment #7) > Partially fixed in issue 5385. Which testcases did I miss?
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.
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.