www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19539] New: Interface address is offset 16bytes, causing

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

          Issue ID: 19539
           Summary: Interface address is offset 16bytes, causing memory
                    leaks
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ihcuo21 gmail.com

code example
-----------------------

import std.stdio;
import core.memory;

interface A {
        int func();
}

class AX : A {
        override int func() {
                return 1;
        }

        char[100] data;
}

void main() {

        AX ax = new AX;
        A a = ax;

        //the offset is 16 bytes
        writeln(cast(void*)ax);
        writeln(cast(void*)a);

        //delete will not free memory because "a" does not point to allocated
block
        __delete(a);
}

-----------------------

--
Jan 02