www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Odd delegate behavior

reply nobody <nobody mailinator.com> writes:
When I compile (v1.0) the following code for some reason opIndexDg's stack 
pointer is null and opIndexAssignDg's stack pointer is not.

----------------
   struct S
   {
     real delegate(size_t i, size_t j) opIndexDg;
     real delegate(real r, size_t i, size_t j) opIndexAssignDg;

     void dbg()
     {
       printf("&opIndexDg : [%X]\n", &opIndexDg );
       printf("     func -> [%X]\n", opIndexDg.funcptr );
       printf("    stack -> [%X]\n", opIndexDg.ptr );

       printf("&opIndexAssignDg : [%X]\n", &opIndexAssignDg );
       printf("           func -> [%X]\n", opIndexAssignDg.funcptr );
       printf("          stack -> [%X]\n", &opIndexAssignDg.ptr );
     }

   };


   int main(char[][] args)
   {
     S s;
     s.dbg();
     return 0;
   }
----------------

Output:

----------------

&opIndexDg : [12FF28]
      func -> [0]
     stack -> [0]
&opIndexAssignDg : [12FF30]
            func -> [0]
           stack -> [12FF30]
Feb 14 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
nobody wrote:
 When I compile (v1.0) the following code for some reason opIndexDg's 
 stack pointer is null and opIndexAssignDg's stack pointer is not.
 
 ----------------

       printf("    stack -> [%X]\n", opIndexDg.ptr );

       printf("          stack -> [%X]\n", &opIndexAssignDg.ptr );

If you remove that it should also be null (it was for me). The address you were printing was where the null pointer was stored, not the null pointer itself :P.
Feb 14 2007
parent nobody <nobody mailinator.com> writes:
Frits van Bommel wrote:
 nobody wrote:
 When I compile (v1.0) the following code for some reason opIndexDg's 
 stack pointer is null and opIndexAssignDg's stack pointer is not.

 ----------------

       printf("    stack -> [%X]\n", opIndexDg.ptr );

       printf("          stack -> [%X]\n", &opIndexAssignDg.ptr );

If you remove that it should also be null (it was for me). The address you were printing was where the null pointer was stored, not the null pointer itself :P.

Thanks that certainly was just a typo on my part!
Feb 14 2007