www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15618] New: [REG-master] Class member layout has been

https://issues.dlang.org/show_bug.cgi?id=15618

          Issue ID: 15618
           Summary: [REG-master] Class member layout has been changed, ABI
                    needs to be updated?
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

To fix issue 15579, PR 5361 was merged.
https://github.com/D-Programming-Language/dmd/pull/5361.

But I noticed that it has changed extern (D) class layout, not only for extern
(C++).
https://github.com/D-Programming-Language/dmd/pull/5361/files#r51126555

Test case:

extern (D) //extern (C++)
{
    class Base
    {
        ~this() {}
        size_t x = 4;
    }

    interface Interface
    {
        int Method();
    }

    class Derived : Base, Interface
    {
        size_t y = 5;
        int Method() { return 3; }
    }
}

void main()
{
    Derived d;                  // dmd 2.069             master
    pragma(msg, d.x.offsetof);  // (void*).sizeof * 2
    pragma(msg, d.y.offsetof);  // (void*).sizeof * 3 -> 4
}

I'm not sure it was expected, so I open this regression issue. If it's an
intentional change, we should update http://dlang.org/spec/abi ABI page, so
there's an explanation for D class object layout.

--
Jan 28