www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10158] New: 'offsetof' property of nested struct does not work properly

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

           Summary: 'offsetof' property of nested struct does not work
                    properly
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kekeniro2 yahoo.co.jp



I tried to write inline assembly code,
but 'offsetof' of nested struct does not work properly.

Code:
class Outer {
    static struct Inner {
        int f;
    }

    // from member of Outer class
    void test()
    {
        static assert( Inner.f.offsetof == 0); // NG
        static assert( (Inner.f).offsetof == 0); // OK, but doesn't cooperate
with the inline assembler

        // Here comes asm { ... }. 
    }
}

// cf. from non-member of Outer class
void main()
{
    static assert( Outer.Inner.f.offsetof == 0); // OK
}

Output:
offsetof_bug.d(9): Error: this for f needs to be type Inner not type
offsetof_bug.Outer

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 23 2013