[Issue 13875] New: extern(C++) interfaces cannot be used as associative array keys
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Dec 17 10:33:42 PST 2014
https://issues.dlang.org/show_bug.cgi?id=13875
Issue ID: 13875
Summary: extern(C++) interfaces cannot be used as associative
array keys
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: redballoon36 at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list