[Issue 10966] Leaked destruction in static array postblit

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 5 20:28:35 PDT 2013


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



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2013-09-05 20:28:34 PDT ---
More reduced test case:

extern(C) int printf(const char*, ...);

void main()
{
    int s;
    int[4] ss;
    bug10966(&ss[0], &s, ss.length, int.sizeof);
}

void* bug10966(void* p, void* value, int count, size_t element_size)
{
    // with -O, variable pstart is wrongly made an alias of p
    void* pstart = p;

    try
    {
        printf("+pstart = %p, p = %p\n", pstart, p);
        foreach (i; 0 .. count)
        {
            if (i == 2) throw new Exception("dummy");
            printf("postblit p = %p\n", p);
            p += element_size;
        }
    }
    catch (Throwable o)
    {
        printf("-pstart = %p, p = %p\n", pstart, p);
        assert(p != pstart);    // asserts with -O
        while (p > pstart)
        {
            p -= element_size;
            printf("destroy p = %p\n", p);
        }
    }
    return pstart;
}

-- 
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