Thread overview | |||||
---|---|---|---|---|---|
|
February 14, 2007 Odd delegate behavior | ||||
---|---|---|---|---|
| ||||
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] |
February 14, 2007 Re: Odd delegate behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to nobody | 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. > > ---------------- [snip] > printf(" stack -> [%X]\n", opIndexDg.ptr ); [snip] > printf(" stack -> [%X]\n", &opIndexAssignDg.ptr ); ^ You have an extra '&' here 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. |
February 14, 2007 Re: Odd delegate behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frits van Bommel | 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.
>>
>> ----------------
> [snip]
>> printf(" stack -> [%X]\n", opIndexDg.ptr );
> [snip]
>> printf(" stack -> [%X]\n", &opIndexAssignDg.ptr );
> ^ You have an extra '&' here
>
> 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!
|
Copyright © 1999-2021 by the D Language Foundation