delegate memory layout help needed

nobody nobody at mailinator.com
Tue Feb 13 11:45:34 PST 2007


I am trying to debug some code that behaves strangely around delegates. I have 
been assuming that delegates are just structs with two int-sized fields (just 
like arrays). Is this correct? Is this struct defined anywhere in DMD supplied D 
code?

More importantly I have been trying to watch two delegate members of a struct to 
  make sure they are getting initialized:

     printf("&opIndexDg : [%X]\n", opIndexDg );
     printf("    +0 -> [%X]\n", *(cast(int*)(&opIndexDg)+0) );
     printf("    +1 -> [%X]\n", *(cast(int*)(&opIndexDg)+1) );

     printf("&opIndexAssignDg : [%X]\n", &opIndexAssignDg );
     printf("     +0 -> [%X]\n", *(cast(int*)(&opIndexAssignDg)+0) );
     printf("     +1 -> [%X]\n", *(cast(int*)(&opIndexAssignDg)+1) );

According to what I have seen the delegates in the struct are getting 
initialized but I keep getting an Array Bounds Error unless I do the exact same 
assignment done during the initialization afterwards in main(). Am I correctly 
interpreting the memory layout?


More information about the Digitalmars-d-learn mailing list