digitalmars.D.bugs - [class properties] Bugs
- Jarrett Billingsley (28/28) Apr 22 2005 Was looking through the D changelog and found that .sizeof was made
-
Jarrett Billingsley
(24/24)
Apr 22 2005
"Jarrett Billingsley"
wrote in message - Thomas Kuehne (18/46) Apr 22 2005 -----BEGIN PGP SIGNED MESSAGE-----
Was looking through the D changelog and found that .sizeof was made un-overridable. I remember when it wasn't.. in any case, I had a hunch, and tried a few other things. I found two more bugs. import std.stdio; class A { static uint alignof() { return 30; } int b; } void main() { // this really shouldn't be legal writefln(A.alignof); // this line causes errors //writefln(A.b.offsetof); } Note that .alignof can be redefined (bad), and for some reason, .offsetof causes the following errors: dtest.d(19): 'this' is only allowed in non-static member functions dtest.d(19): this for b needs to be type A not type int Using .offsetof on a member of an instantiated A works, however. This is inconsistent with the struct behavior, which is exactly the opposite - gives an error when trying to use .offsetof on a member of an instantiated struct, but works when using the struct type (i.e. for struct A with member b, A.b.offsetof).
Apr 22 2005
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:d4c3qc$eu8$1 digitaldaemon.com... Just found another! I can overload offsetof as well. import std.stdio; class A { this() { b=new B; } class B { uint offsetof() { return 6756; } } B b; } void main() { A a=new A; writefln(a.b.offsetof); }
Apr 22 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jarrett Billingsley schrieb am Fri, 22 Apr 2005 20:14:42 -0400:Was looking through the D changelog and found that .sizeof was made un-overridable. I remember when it wasn't.. in any case, I had a hunch, and tried a few other things. I found two more bugs. import std.stdio; class A { static uint alignof() { return 30; } int b; } void main() { // this really shouldn't be legal writefln(A.alignof); // this line causes errors //writefln(A.b.offsetof); } Note that .alignof can be redefined (bad), and for some reason, .offsetof causes the following errors: dtest.d(19): 'this' is only allowed in non-static member functions dtest.d(19): this for b needs to be type A not type int Using .offsetof on a member of an instantiated A works, however. This is inconsistent with the struct behavior, which is exactly the opposite - gives an error when trying to use .offsetof on a member of an instantiated struct, but works when using the struct type (i.e. for struct A with member b, A.b.offsetof).Added to DStress as http://dstress.kuehne.cn/nocompile/alignof_01.d http://dstress.kuehne.cn/nocompile/alignof_02.d http://dstress.kuehne.cn/nocompile/alignof_03.d http://dstress.kuehne.cn/nocompile/alignof_04.d http://dstress.kuehne.cn/nocompile/offsetof_74.d http://dstress.kuehne.cn/nocompile/offsetof_75.d http://dstress.kuehne.cn/nocompile/offsetof_76.d http://dstress.kuehne.cn/nocompile/offsetof_77.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCaeiG3w+/yD4P9tIRAr1UAJ9S2sXkQ3Cwf8AWvDzQsNPq2kaU8QCeMc7s BDiYNpoCqpaM++WZpSNgmA0= =7b4/ -----END PGP SIGNATURE-----
Apr 22 2005