[Issue 3897] New: Sporadic incorrectness with builtin AAs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 8 06:38:44 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3897

           Summary: Sporadic incorrectness with builtin AAs
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2010-03-08 06:38:43 PST ---
Here's about the best I can do to reproduce this issue.  It showed up in a
monte carlo unittest of one of my associative array implementations that tested
whether it gets the same answers as the builtin implementation.  Probably some
subtle memory corruption issue.

import std.stdio, std.random, std.conv;

void main() {
    // Monte carlo unit test builtin hash table.
    uint[uint] table;
    auto gen = Random(42);
    foreach(i; 0..1_000_000) {
        auto num1 = gen.front();
        gen.popFront();
        auto num2 = gen.front();
        gen.popFront();

        table[num1] = num2;
    }

    // Note that we're using the same seed again.
    gen = Random(42);
    foreach(i; 0..1_000_000) {
        auto num1 = gen.front();
        gen.popFront();
        auto num2 = gen.front();
        gen.popFront();

        assert(num1 in table);
        assert(table[num1] == num2);
    }
}

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


More information about the Digitalmars-d-bugs mailing list