digitalmars.D.bugs - [Issue 15765] New: TypeInfo for C++ classes uses wrong vtbl
- via Digitalmars-d-bugs (45/45) Mar 05 2016 https://issues.dlang.org/show_bug.cgi?id=15765
https://issues.dlang.org/show_bug.cgi?id=15765 Issue ID: 15765 Summary: TypeInfo for C++ classes uses wrong vtbl Product: D Version: D2 Hardware: All OS: Linux Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: code dawg.eu 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. --
Mar 05 2016