April 20, 2005 private static bug | ||||
---|---|---|---|---|
| ||||
<other.d> class MyClass { static: private int _staticVariable; } <main.d> void test() { MyClass mc = new MyClass(); mc._staticVariable;//NOT accessible (correct) MyClass._staticVariable;//IS accessible (bug in compiler) return; } As you can see from this example, private static variables can still be accessed from outside the module, if the private static is called from its class. |
April 20, 2005 Re: private static bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to imr1984 | -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 imr1984 schrieb am Wed, 20 Apr 2005 10:13:27 +0000 (UTC): ><other.d> > class MyClass > { > static: > > private int _staticVariable; > } > ><main.d> > void test() > { > MyClass mc = new MyClass(); > mc._staticVariable;//NOT accessible (correct) > MyClass._staticVariable;//IS accessible (bug in compiler) > return; > } > > As you can see from this example, private static variables can still be accessed from outside the module, if the private static is called from its class. Added to DStress as http://dstress.kuehne.cn/nocompile/private_05.d http://dstress.kuehne.cn/nocompile/private_06.d http://dstress.kuehne.cn/addon/private_05_A.d http://dstress.kuehne.cn/nocompile/package_01.d http://dstress.kuehne.cn/nocompile/package_02.d http://dstress.kuehne.cn/addon/package_01_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCZlKM3w+/yD4P9tIRAh0uAJ9+qsuABCM41AA22+KHT0y4iD5HQgCfe2bJ /OIHleuAJ7ooPgqPEbcABbw= =tzAG -----END PGP SIGNATURE----- |
Copyright © 1999-2021 by the D Language Foundation