Thread overview
[Issue 1712] New: vtbl[0] for interface not set to corresponding Interface*
Dec 03, 2007
d-bugmail
Jan 20, 2008
d-bugmail
Jan 20, 2008
d-bugmail
Jan 21, 2008
d-bugmail
May 11, 2008
d-bugmail
December 03, 2007
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'
---


-- 

January 20, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1712


bugzilla@digitalmars.com changed:

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




------- Comment #1 from bugzilla@digitalmars.com  2008-01-20 00:48 -------
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.


-- 

January 20, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1712


dhasenan@gmail.com changed:

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




------- Comment #2 from dhasenan@gmail.com  2008-01-20 10:53 -------
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.


-- 

January 21, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1712





------- Comment #3 from dhasenan@gmail.com  2008-01-21 09:13 -------
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.


-- 

May 11, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1712


bugzilla@digitalmars.com changed:

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




------- Comment #4 from bugzilla@digitalmars.com  2008-05-11 04:12 -------
Fixed dmd 1.029 and 2.013


--