Bug 15765 – TypeInfo for C++ classes uses wrong vtbl

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2016-03-05T12:38:41Z
Last change time
2020-02-19T05:23:03Z
Assigned to
No Owner
Creator
Martin Nowak

Comments

Comment #0 by code — 2016-03-05T12:38:41Z
cat > bug.d << CODE extern (C++) class RootObject { bool equals(RootObject o) { return o is this; } int compare(RootObject) { assert(0); } void print() { assert(0, "Should not get called"); } } void main() { bool[RootObject] aa; aa[new RootObject] = true; } CODE ---- dmd -run bug ---- Because TypeInfo_Class casts every void* to a standard Object, it ends up calling the wrong vtable entries for operations like getHash. I think we need a dedicated TypeInfo_CppClass that is similar to TypeInfo_Struct with it's xopEquals and xopHash in order to fix this bug. C++ classes don't inherit from the common Object class, so those methods must not exist.
Comment #1 by pro.mathias.lang — 2020-02-19T05:23:03Z
Marking of duplicate of 15813 since this issue is the more "user-facing" bug. *** This issue has been marked as a duplicate of issue 15813 ***