www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4184] New: associative array with certain key types results in corrupt values during iteration

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184

           Summary: associative array with certain key types results in
                    corrupt values during iteration
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: sean invisibleduck.org
        ReportedBy: schveiguy yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy yahoo.com> 2010-05-13
10:38:05 PDT ---
The following code:

import std.stdio;

void main()
{
    uint[ushort] aa;
    aa[1] = 1;
    aa[2] = 2;
    aa[3] = 3;
    aa[4] = 4;
    aa[5] = 5;
    writefln("%s", aa);
    foreach(ushort k, uint v; aa)
    {
        writefln("%s => %s", k, v);
    }
}

results in the following output:

[4:4,1:1,5:5,2:2,3:3]
4 => 262144
1 => 65536
5 => 327680
2 => 131072
3 => 196608

Clearly, the data is stored correctly, or else writefln would not be able to
get the correct values when displaying the AA directly.  However, the iteration
code is getting corrupt values.

I suspect this is probably a druntime issue.  It was introduced somewhere
between 2.033 (which works) and 2.036 (I haven't yet downloaded the
intermediate versions).

I will see if I can find the cause and commit a patch.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|druntime                    |DMD
         AssignedTo|sean invisibleduck.org      |nobody puremagic.com


--- Comment #1 from Steven Schveighoffer <schveiguy yahoo.com> 2010-05-13
11:02:08 PDT ---
wow, nevermind, it is probably dmd.

Compiling this simple function results in pages and pages of AA functions in
disassembly, I'm not sure if druntime has anything to do with this bug.

void foo(uint[ushort] aa)
{
    foreach(ushort k, uint v; aa)
    {
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2010-05-13
17:19:42 PDT ---
Printing things in hex yields 40000, 10000, 50000, 20000, 30000. Hmm.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2010-05-13
17:55:50 PDT ---
changeset 295

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184



--- Comment #4 from Steven Schveighoffer <schveiguy yahoo.com> 2010-05-13
19:46:10 PDT ---
Great, thanks!

No wonder there was so much code generated, it's a template :)  I didn't know
the compiler associated AA's with a template.

I'll test against dcollections tomorrow.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184



--- Comment #5 from Steven Schveighoffer <schveiguy yahoo.com> 2010-05-14
04:31:27 PDT ---
I confirm, it fixes the problems in dcollections, thanks.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 14 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4184


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Jesse.K.Phillips+D gmail.co
                   |                            |m


--- Comment #6 from Steven Schveighoffer <schveiguy yahoo.com> 2010-05-19
10:15:28 PDT ---
*** Issue 4209 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 19 2010