[Issue 20375] New: std.typecons.RefCounted does not work with checkaction-context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Nov 9 22:33:55 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20375

          Issue ID: 20375
           Summary: std.typecons.RefCounted does not work with
                    checkaction-context
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: moonlightsentinel at disroot.org

Using checkation=context results in another temporary which gets destroyed but
not constructed by any declared constructor.

Reduced test case:

struct RefCounted
{
    static int instances;

    this(bool data)
    {
        instances++;
    }

    this(this)
    {
        instances++;
    }

    ~this()
    {
        instances--;
    }

    bool opEquals(RefCounted)
    {
        return true;
    }
}

{
    auto a = RefCounted(true);
    assert(a == a);
}

assert(RefCounted.instances == 0);

--


More information about the Digitalmars-d-bugs mailing list