[Issue 10158] New: 'offsetof' property of nested struct does not work properly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 23 19:53:46 PDT 2013


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 at puremagic.com
        ReportedBy: kekeniro2 at yahoo.co.jp


--- Comment #0 from kekeniro2 at yahoo.co.jp 2013-05-23 19:53:45 PDT ---
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: -------


More information about the Digitalmars-d-bugs mailing list