Bug 13875 – extern(C++) interfaces cannot be used as associative array keys

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-17T18:33:42Z
Last change time
2020-02-19T05:21:25Z
Keywords
C++, wrong-code
Assigned to
No Owner
Creator
Paul O'Neil
See also
https://issues.dlang.org/show_bug.cgi?id=15813

Comments

Comment #0 by redballoon36 — 2014-12-17T18:33:42Z
Example code: test.cpp: class Inter { virtual ~Inter() { } }; Inter * newInter() { return new Inter; } test.d: extern(C++) interface Inter { } extern(C++) Inter newInter(); void main() { int[Inter] map; Inter i = newInter(); map[i] = 5; } Compiling these two files succeeds. The generated code segmentation faults in: #0 0x000000000041aac9 in object.TypeInfo_Interface.getHash(const(void*)) () #1 0x000000000041b1a2 in _aaGetX () #2 0x000000000041a50a in D main () at test.d:11 If this is not supposed to be allowed, since Inter does not have the right toHash or something, then I think that int[Inter] should produce an error.
Comment #1 by pro.mathias.lang — 2020-02-19T05:21:25Z
Duplicate of 15813. Technically, it is the other way around, since your issue is 16 months older, but 15813 has a more encompassing title (it also happens with classes). *** This issue has been marked as a duplicate of issue 15813 ***