www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1712] New: vtbl[0] for interface not set to corresponding Interface*

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1712

           Summary: vtbl[0] for interface not set to corresponding
                    Interface*
           Product: D
           Version: 2.008
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dhasenan gmail.com


From the spec:
"""
struct Interface;
    Information about an interface. A pointer to this appears as the first
entry in the interface's vtbl[].
"""

By implication, the vtbl has to be a void* array of length one, and the first
entry must be non-null.

---
interface IFoo {};

writefln("%x", IFoo.classinfo.vtbl.ptr); // prints '0'
---


-- 
Dec 02 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1712


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





The vtbl[] for an interface is not in the interface's classinfo, as the vtbl[]
is not generated by the interface definition, but by the class definition that
implements the interface.


-- 
Jan 19 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1712


dhasenan gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |





So you're saying that the Interface* should appear in the vtbl of each
implementing class? Like this:

---
interface IFoo {}
class Foo : IFoo {}

// Foo implements one more interface than Object, so its vtbl includes
// one Interface* that Object doesn't. Nothing else is specific to Foo.
assert(Object.classinfo.vtbl.length + 1 == Foo.classinfo.vtbl.length);
---

Except that doesn't work.

I understand that the vtbl of an interface should not include any function
pointers. However, the spec says it should hold an Interface*.
http://www.digitalmars.com/d/phobos/object.html if you want the link. Either
the spec is incorrect or the implementation is incorrect. If the spec is
incorrect, then I cannot proxy certain objects, and you should alter the
documentation.

Or is there some other vtbl in which the Interface* should appear? If so, the
documentation is far from clear on the matter and should be altered.


-- 
Jan 20 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1712






Please amend the documentation to say:
"When an object is accessed via an interface, an Interface* appears as the
first entry in its vtbl."

Thanks to Bill Baxter for digging up a link related to this issue.


-- 
Jan 21 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1712


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED





Fixed dmd 1.029 and 2.013


-- 
May 11 2008