The spec has code amounting to the following, under "Field Properties": class Foo { int x; } void main() { Foo foo = new Foo(); size_t o; o = Foo.x.offsetof; o = foo.x.offsetof; } The spec states that the above of the two assignments to o should yield 8 and the below should fail to compile. DMD's behaviour is precisely the opposite. The explanation confused me somewhere around "fields qualified with the type of the class" so I'm not sure which is right, but one of the two - the spec, or DMD - has to be wrong.
The spec makes more sense than what the compiler is doing. I'm therefore inclined that DMD is wrong.
*** Bug 979 has been marked as a duplicate of this bug. ***
Updated the severity etc. from #979.
Just a ping that the spec (http://www.digitalmars.com/d/1.0/class.html) is still not in line with the compiler (DMD 1.031). You can see it first mentioned regarding DMD 0.131 back in 2005 here: http://www.digitalmars.com/d/archives/digitalmars/D/bugs/4988.html Just to recap: In the compiler Foo.init.x.offsetof works. Foo.x.offsetof does not. Spec says the opposite is true.
*** Bug 2202 has been marked as a duplicate of this bug. ***
There's a typo in the updated doc now: ".offsetof can only be applied to not expressions" I'll file a different bug though. This basic issue of this bug has been fixed by changing the spec.
Fixed dmd 1.032 and 2.016
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル