www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2358] New: offsetof inconsistent between structs and classes

http://d.puremagic.com/issues/show_bug.cgi?id=2358

           Summary: offsetof inconsistent between structs and classes
           Product: D
           Version: 1.035
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid, spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: kamm-removethis incasoftware.de


For classes .offsetof works only on the instance and for structs it only works
on the declaration:

--
class C { int x; }
struct S { int x; }

void main() {
  S s;
  C c = new C;

  auto c1 = c.x.offsetof;
  auto c2 = C.x.offsetof; // error
  auto s1 = s.x.offsetof; // error
  auto s2 = S.x.offsetof;
}
--

For classes, the situation is documented. For structs, the spec merely says
that the offsetof property exists. I expect all combinations could me made
legal.


-- 
Sep 12 2008