www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 515] New: Spec incorrect in where .offsetof can be applied

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515

           Summary: Spec incorrect in where .offsetof can be applied
           Product: D
           Version: 0.174
          Platform: PC
               URL: http://www.digitalmars.com/d/class.html
        OS/Version: Windows
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P4
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: deewiant gmail.com
OtherBugsDependingO 511
             nThis:


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.


-- 
Nov 15 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |accepts-invalid, rejects-
                   |                            |valid





The spec makes more sense than what the compiler is doing.  I'm therefore
inclined that DMD is wrong.


-- 
Dec 11 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515


onlystupidspamhere yahoo.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |benoit tionex.de





*** Bug 979 has been marked as a duplicate of this bug. ***


-- 
Jun 17 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515


onlystupidspamhere yahoo.se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major
         OS/Version|Windows                     |All
           Priority|P4                          |P2








-- 
Jun 17 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515






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.


-- 
Jul 02 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samukha voliacable.com





*** Bug 2202 has been marked as a duplicate of this bug. ***


-- 
Jul 08 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515


wbaxter gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





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.


-- 
Jul 09 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=515






Fixed dmd 1.032 and 2.016


-- 
Jul 09 2008