Thread overview
? key in AssociativeArray
Dec 06, 2004
Thomas Kuehne
Dec 06, 2004
Regan Heath
Dec 07, 2004
Simon Buchan
Dec 07, 2004
Thomas Kuehne
Dec 07, 2004
Ben Hinkle
Descriptive names
Dec 09, 2004
Simon Buchan
Dec 09, 2004
Ben Hinkle
December 06, 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

code:
# int main(){
#        int value = 1;
#        char[] key = "eins";
#        int[char[]] array;
#        array[key]=value;
#        int* ptr = key in array;
#
#        printf("&value: %x\t%d\n", &value, &value);
#        printf("&key:   %x\t%d\n", &key, &key);
#        printf("&array: %x\t%d\n", &array, &array);
#        printf("ptr:    %x\t%d\n", ptr, ptr);
#        printf("*ptr:   %x\t%d\n", *ptr, *ptr);
#        return 0;
# }

output:
# &value: bffff570 -1073744528
# &key:   bffff578 -1073744520
# &array: bffff580 -1073744512
# ptr:    401a5fb0 1075470256
# *ptr:   8052144  134553924

According to the docu ptr should be pointing to the value or NULL.

PTR is pointing to NULL if the key isn't present in the array - but where is it pointing to if the key is present?

Am I missing something?

Thomas

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.9.13 (GNU/Linux)

iD8DBQFBtDbN3w+/yD4P9tIRAhClAKDKQfFnreY4xVlTAGzi4a8N38PVjQCeNjRW
ob5F5v6SXTBhM3aCUWhNkLQ=
=vJ+R
-----END PGP SIGNATURE-----
December 06, 2004
On Mon, 6 Dec 2004 11:39:10 +0100, Thomas Kuehne <thomas-dloop@kuehne.thisisspam.cn> wrote:
> code:
> # int main(){
> #        int value = 1;
> #        char[] key = "eins";
> #        int[char[]] array;
> #        array[key]=value;
> #        int* ptr = key in array;
> #
> #        printf("&value: %x\t%d\n", &value, &value);
> #        printf("&key:   %x\t%d\n", &key, &key);
> #        printf("&array: %x\t%d\n", &array, &array);
> #        printf("ptr:    %x\t%d\n", ptr, ptr);
> #        printf("*ptr:   %x\t%d\n", *ptr, *ptr);
> #        return 0;
> # }
>
> output:
> # &value: bffff570 -1073744528
> # &key:   bffff578 -1073744520
> # &array: bffff580 -1073744512
> # ptr:    401a5fb0 1075470256
> # *ptr:   8052144  134553924
>
> According to the docu ptr should be pointing to the value or NULL.
>
> PTR is pointing to NULL if the key isn't present in the array - but where
> is it pointing to if the key is present?
>
> Am I missing something?

If you are, so am I. :)

# int main(){
#        int value = 1;
#        char[] key = "eins";
#        int[char[]] array;
#        array[key]=value;
#        int* ptr = key in array;
#
#        printf("&value:      %x\t%d\n", &value, value);
#        printf("&array[key]: %x\t%d\n", &array[key], array[key]);
#        printf("ptr:         %x\t%d\n", ptr, *ptr);
#        printf("ptr:         %x\t%d\n", ptr+1, *(ptr+1));
#        return 0;
# }

D:\D\src\temp>keyin
&value:      12ff18     1
&array[key]: 870fd4     1
ptr:         870fd0     4264064
ptr:         870fd4     1

The first thing I thought was, when you add an 'int' to an array it copies the int creating a new one, so &value wont == &array[key], BUT, ptr should == &array[key].

My results seem to show that it's out by 4 bytes, 32 bits, or 1 int.

Regan
December 07, 2004
On Tue, 07 Dec 2004 09:04:28 +1300, Regan Heath <regan@netwin.co.nz> wrote:

<snip>
>
> If you are, so am I. :)
>
> # int main(){
> #        int value = 1;
> #        char[] key = "eins";
> #        int[char[]] array;
> #        array[key]=value;
> #        int* ptr = key in array;
> #
> #        printf("&value:      %x\t%d\n", &value, value);
> #        printf("&array[key]: %x\t%d\n", &array[key], array[key]);
> #        printf("ptr:         %x\t%d\n", ptr, *ptr);
> #        printf("ptr:         %x\t%d\n", ptr+1, *(ptr+1));
> #        return 0;
> # }
>
> D:\D\src\temp>keyin
> &value:      12ff18     1
> &array[key]: 870fd4     1
> ptr:         870fd0     4264064
> ptr:         870fd4     1
>
> The first thing I thought was, when you add an 'int' to an array it copies the int creating a new one, so &value wont == &array[key], BUT, ptr should == &array[key].
>
> My results seem to show that it's out by 4 bytes, 32 bits, or 1 int.
>
> Regan

"InExpressions now, instead of returning a bit, return a pointer to the
associative array element if the key is present, null if it is not."

Looks like Walter forgot to check it. Looks like an implementation
thing, like it points to the hash of the key or something.
0x00411080 (*ptr in hex) does look like a string literal hash...

-- 
"Unhappy Microsoft customers have a funny way of becoming Linux,
Salesforce.com and Oracle customers." - www.microsoft-watch.com:
"The Year in Review: Microsoft Opens Up"
December 07, 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"key in AssociativeArray" returns botched pointers

http://svn.kuehne.cn/dstress/run/InExpression_01.d
http://svn.kuehne.cn/dstress/run/InExpression_02.d
...
http://svn.kuehne.cn/dstress/run/InExpression_09.d
http://svn.kuehne.cn/dstress/run/InExpression_10.d

Thomas

Simon Buchan schrieb am Tue, 07 Dec 2004 19:12:10 +1300:
> On Tue, 07 Dec 2004 09:04:28 +1300, Regan Heath <regan@netwin.co.nz> wrote:
>>
>> # int main(){
>> #        int value = 1;
>> #        char[] key = "eins";
>> #        int[char[]] array;
>> #        array[key]=value;
>> #        int* ptr = key in array;
>> #
>> #        printf("&value:      %x\t%d\n", &value, value);
>> #        printf("&array[key]: %x\t%d\n", &array[key], array[key]);
>> #        printf("ptr:         %x\t%d\n", ptr, *ptr);
>> #        printf("ptr:         %x\t%d\n", ptr+1, *(ptr+1));
>> #        return 0;
>> # }
>>
>> D:\D\src\temp>keyin
>> &value:      12ff18     1
>> &array[key]: 870fd4     1
>> ptr:         870fd0     4264064
>> ptr:         870fd4     1
>>
>> The first thing I thought was, when you add an 'int' to an array it copies the int creating a new one, so &value wont == &array[key], BUT, ptr should == &array[key].

> 0x00411080 (*ptr in hex) does look like a string literal hash...

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.9.13 (GNU/Linux)

iD8DBQFBtaEw3w+/yD4P9tIRAp06AKDRXohxpHwub5nFhKYVAKjwilo3hgCfQZS8
mw1CVKPcD1OYIL/Ooe5Neeo=
=1Hph
-----END PGP SIGNATURE-----
December 07, 2004
Looking at aaA.d I think the bug will be fixed by changing line 270 from
   return cast(void *)(e + 1) + keyti.sizeof;
to
   return cast(void *)(e + 1) + keyti.tsize();


"Thomas Kuehne" <thomas-dloop@kuehne.thisisspam.cn> wrote in message news:g2kg82-imj.ln1@kuehne.cn...
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> "key in AssociativeArray" returns botched pointers
>
> http://svn.kuehne.cn/dstress/run/InExpression_01.d
> http://svn.kuehne.cn/dstress/run/InExpression_02.d
> ...
> http://svn.kuehne.cn/dstress/run/InExpression_09.d
> http://svn.kuehne.cn/dstress/run/InExpression_10.d
>
> Thomas
>
> Simon Buchan schrieb am Tue, 07 Dec 2004 19:12:10 +1300:
>> On Tue, 07 Dec 2004 09:04:28 +1300, Regan Heath <regan@netwin.co.nz> wrote:
>>>
>>> # int main(){
>>> #        int value = 1;
>>> #        char[] key = "eins";
>>> #        int[char[]] array;
>>> #        array[key]=value;
>>> #        int* ptr = key in array;
>>> #
>>> #        printf("&value:      %x\t%d\n", &value, value);
>>> #        printf("&array[key]: %x\t%d\n", &array[key], array[key]);
>>> #        printf("ptr:         %x\t%d\n", ptr, *ptr);
>>> #        printf("ptr:         %x\t%d\n", ptr+1, *(ptr+1));
>>> #        return 0;
>>> # }
>>>
>>> D:\D\src\temp>keyin
>>> &value:      12ff18     1
>>> &array[key]: 870fd4     1
>>> ptr:         870fd0     4264064
>>> ptr:         870fd4     1
>>>
>>> The first thing I thought was, when you add an 'int' to an array it copies the int creating a new one, so &value wont == &array[key], BUT, ptr should == &array[key].
>
>> 0x00411080 (*ptr in hex) does look like a string literal hash...
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.9.13 (GNU/Linux)
>
> iD8DBQFBtaEw3w+/yD4P9tIRAp06AKDRXohxpHwub5nFhKYVAKjwilo3hgCfQZS8
> mw1CVKPcD1OYIL/Ooe5Neeo=
> =1Hph
> -----END PGP SIGNATURE----- 


December 09, 2004
On Tue, 7 Dec 2004 08:12:41 -0500, Ben Hinkle <ben.hinkle@gmail.com> wrote:

> Looking at aaA.d I think the bug will be fixed by changing line 270 from
<snip>

Got to love the desciptive names :D


-- 
"Unhappy Microsoft customers have a funny way of becoming Linux,
Salesforce.com and Oracle customers." - www.microsoft-watch.com:
"The Year in Review: Microsoft Opens Up"
--
"I plan on at least one critical patch every month, and I haven't been disappointed."
- Adam Hansen, manager of security at Sonnenschein Nath & Rosenthal LLP
(Quote from http://www.eweek.com/article2/0,1759,1736104,00.asp)
--
"It's been a challenge to "reteach or retrain" Web users to pay for content, said Pizey"
-Wired website: "The Incredible Shrinking Comic"
December 09, 2004
"Simon Buchan" <currently@no.where> wrote in message news:opsiqubhtdjccy7t@simon.mshome.net...
> On Tue, 7 Dec 2004 08:12:41 -0500, Ben Hinkle <ben.hinkle@gmail.com>
wrote:
>
> > Looking at aaA.d I think the bug will be fixed by changing line 270 from
> <snip>
>
> Got to love the desciptive names :D

yeah - kindof like the error messages from the compiler talking about Internal error: ..\ztc\cg87.c 1219

I'm guessing the ztc is from Zortech C or something but it reads like Kingon :-P.