515 – Spec incorrect in where .offsetof can be applied

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 515 - Spec incorrect in where .offsetof can be applied
Summary: Spec incorrect in where .offsetof can be applied
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 major
Assignee: Walter Bright
URL: http://www.digitalmars.com/d/class.html
Keywords: accepts-invalid, rejects-valid, spec
: 979 (view as issue list)
Depends on:
Blocks: 511
Show dependency tree / graph
Reported: 2006年11月15日 07:01 UTC by Matti Niemenmaa
Modified: 2014年02月15日 13:20 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Matti Niemenmaa 2006年11月15日 07:01:59 UTC
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 Stewart Gordon 2006年12月11日 20:23:27 UTC
The spec makes more sense than what the compiler is doing. I'm therefore inclined that DMD is wrong.
Comment 2 Jari-Matti Mäkelä 2007年06月17日 15:52:11 UTC
*** Bug 979 has been marked as a duplicate of this bug. ***
Comment 3 Jari-Matti Mäkelä 2007年06月17日 15:54:49 UTC
Updated the severity etc. from #979.
Comment 4 Bill Baxter 2008年07月02日 03:52:05 UTC
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 david 2008年07月08日 06:01:56 UTC
*** Bug 2202 has been marked as a duplicate of this bug. ***
Comment 6 Bill Baxter 2008年07月09日 06:44:45 UTC
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 Walter Bright 2008年07月09日 22:33:11 UTC
Fixed dmd 1.032 and 2.016


AltStyle によって変換されたページ (->オリジナル) /