Thread overview
[Issue 14595] [REG2.066] RefCounted data corrupted when in an AA
May 17, 2015
Vladimir Panteleev
May 17, 2015
Vladimir Panteleev
May 17, 2015
Vladimir Panteleev
May 17, 2015
Vladimir Panteleev
Jun 01, 2015
Kenji Hara
Feb 08, 2020
Walter Bright
May 17, 2015
https://issues.dlang.org/show_bug.cgi?id=14595

Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|RefCounted data corrupted   |[REG2.066] RefCounted data
                   |when in an AA               |corrupted when in an AA

--
May 17, 2015
https://issues.dlang.org/show_bug.cgi?id=14595

--- Comment #1 from Vladimir Panteleev <thecybershadow@gmail.com> ---
I have reduced the above to the following code:

//////////// test.d ////////////
struct S
{
    this(int) { }

    bool okToDestroy;

    ~this()
    {
        assert(okToDestroy);
    }
}

S[string] aa;

void main()
{
    aa[null] = S(42);
    aa[null].okToDestroy = true;
}
////////////////////////////////

But this reduction does not manifest as a regression.

--
May 17, 2015
https://issues.dlang.org/show_bug.cgi?id=14595

--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> ---
Alternative reduction:

//////// test.d ////////
struct S
{
    int* count;

    this(int)
    {
        count = new int;
        *count = 1;
    }

    this(this)
    {
        ++count;
    }

    ~this()
    {
        --*count;
    }
}

S[string] aa;

void main()
{
    aa[null] = S(42);
    auto p = null in aa;
    assert(*p.count);
}
////////////////////////

2.064.2: works
2.065.0: ICE
2.066.1: assert fails

--
May 17, 2015
https://issues.dlang.org/show_bug.cgi?id=14595

--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> ---
(In reply to Vladimir Panteleev from comment #2)
>         ++count;

Should be ++*count

--
June 01, 2015
https://issues.dlang.org/show_bug.cgi?id=14595

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
           Hardware|x86_64                      |All
         Resolution|---                         |DUPLICATE
                 OS|Linux                       |All

--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> ---
The root problem is same with issue 14321, and it's already fixed in git-head
(2.068a).

*** This issue has been marked as a duplicate of issue 14321 ***

--
February 08, 2020
https://issues.dlang.org/show_bug.cgi?id=14595

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=17145

--