www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - AAs can't contain references to interfaces

reply Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> writes:
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 :-)
Sep 04 2005
parent Thomas Kühne <thomas-dloop kuehne.cn> writes:
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
Sep 07 2005