September 04, 2005
Hi,

Unless my code is incorrect, we can't have an associative array with interface references? Things go terribly wrong...

#class SlotManager {}
#
#interface GenericSlot
#{
#	void disconnect();
#	SlotManager owner();
#	void deadCode();
#}
#
#class Slot : GenericSlot
#{	
#	void deadCode()	{ printf("This should never be shown!!!\n"); }
#
#	void disconnect() {}
#
#	SlotManager owner() {}
#}
#
#void main(char[][] arg)
#{
#	GenericSlot[GenericSlot] _slots;
#	
#	Slot up;
#
#	up = new Slot();
#	_slots[up]=up; //calls dead code!!!
#}


output:
This should never be shown!!!


Removing any members from the interface produces a segmentation fault, so the execution of dead code appears to be a coinsidence.

dmd 0.129 on Linux.


Best regards,
Bastiaan.

(and thanks again for D :-)
September 07, 2005
In article <dffjik$2p30$1@digitaldaemon.com>, Bastiaan Veelo says...
>
>Hi,
>
>Unless my code is incorrect, we can't have an associative array with interface references? Things go terribly wrong...
>
>#class SlotManager {}
>#
>#interface GenericSlot
>#{
>#	void disconnect();
>#	SlotManager owner();
>#	void deadCode();
>#}
>#
>#class Slot : GenericSlot
>#{
>#	void deadCode()	{ printf("This should never be shown!!!\n"); }
>#
>#	void disconnect() {}
>#
>#	SlotManager owner() {}
>#}
>#
>#void main(char[][] arg)
>#{
>#	GenericSlot[GenericSlot] _slots;
>#
>#	Slot up;
>#
>#	up = new Slot();
>#	_slots[up]=up; //calls dead code!!!
>#}
>
>
>output:
>This should never be shown!!!
>
>
>Removing any members from the interface produces a segmentation fault, so the execution of dead code appears to be a coinsidence.
>
>dmd 0.129 on Linux.

Added to DStress as http://dstress.kuehne.cn/run/a/associative_array_18_A.d http://dstress.kuehne.cn/run/a/associative_array_18_B.d http://dstress.kuehne.cn/run/a/associative_array_18_C.d http://dstress.kuehne.cn/run/a/associative_array_18_D.d

Thomas