Bug 4013 – Inconsistent codeview debug info for classes derived from IUnknown

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Windows
Creation time
2010-03-27T01:14:00Z
Last change time
2014-02-15T13:13:18Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
r.sagitario
Blocks
4044

Comments

Comment #0 by r.sagitario — 2010-03-27T01:14:34Z
IUnknown and any class derived from it have inconsistent codeview debug info: dmd -g -c lib module lib; interface IUnknown { void foo(); } compiles to $$TYPES segment 00: LF_ARGLIST argcount=0 01: LF_VTSHAPE count=1 05 02: LF_CLASS count=1 <typidx 1007> property=x0000 <dList 0000> <vshape 1001> length=x0000 lib.IUnknown 03: LF_CLASS count=0 <typidx 0000> property=x0080 <dList 0000> <vshape 0000> length=x0000 IUnknown 04: LF_POINTER <x000a > <typidx 1003> ... and later referencing the incomplete type 1003. Please note that the class is called "lib.IUnknown" in one entry, but "IUnknown" in the other.
Comment #1 by r.sagitario — 2010-03-27T01:16:14Z
This is caused by using sym->toPrettyChars() most of the time, but sometimes not on cpp-interfaces. I think toPrettyChars() should always be used. Here's a patch: Index: toctype.c =================================================================== --- toctype.c (revision 419) +++ toctype.c (working copy) @@ -381,8 +381,12 @@ /* Need this symbol to do C++ name mangling */ - const char *name = sym->isCPPinterface() ? sym->ident->toChars() - : sym->toPrettyChars(); + const char *name = sym->toPrettyChars(); s = symbol_calloc(name); s->Sclass = SCstruct; s->Sstruct = struct_calloc();
Comment #2 by bugzilla — 2011-02-07T15:29:36Z
The name in both places should be just IUnknown. The reason is because that name is used for C++ name mangling, and has to line up with what the corresponding C++ compiler does with it. https://github.com/D-Programming-Language/dmd/commit/411b1e5faf3a93149fa9b31c3f0946020f48ccd0