Bug 515 – Spec incorrect in where .offsetof can be applied

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2006-11-15T07:01:00Z
Last change time
2014-02-15T13:20:36Z
Keywords
accepts-invalid, rejects-valid, spec
Assigned to
bugzilla
Creator
matti.niemenmaa+dbugzilla
Blocks
511

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2006-11-15T07:01:59Z
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.
Comment #1 by smjg — 2006-12-11T20:23:27Z
The spec makes more sense than what the compiler is doing. I'm therefore inclined that DMD is wrong.
Comment #2 by onlystupidspamhere — 2007-06-17T15:52:11Z
*** Bug 979 has been marked as a duplicate of this bug. ***
Comment #3 by onlystupidspamhere — 2007-06-17T15:54:49Z
Updated the severity etc. from #979.
Comment #4 by wbaxter — 2008-07-02T03:52:05Z
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.
Comment #5 by davidl — 2008-07-08T06:01:56Z
*** Bug 2202 has been marked as a duplicate of this bug. ***
Comment #6 by wbaxter — 2008-07-09T06:44:45Z
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.
Comment #7 by bugzilla — 2008-07-09T22:33:11Z
Fixed dmd 1.032 and 2.016