D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20375 - std.typecons.RefCounted does not work with checkaction-context
Summary: std.typecons.RefCounted does not work with checkaction-context
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-11-09 22:33 UTC by moonlightsentinel
Modified: 2020-02-13 23:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description moonlightsentinel 2019-11-09 22:33:55 UTC
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);
Comment 1 Dlang Bot 2019-11-09 23:19:55 UTC
@MoonlightSentinel created dlang/dmd pull request #10550 "Fix Issue 20375 - RefCounted does not work with checkaction-context" fixing this issue:

- Fix Issue 20375 - std.typecons.RefCounted does not work with checkaction-context

https://github.com/dlang/dmd/pull/10550
Comment 2 Dlang Bot 2020-02-13 23:27:05 UTC
dlang/dmd pull request #10550 "Fix Issue 20375 - RefCounted does not work with checkaction-context" was merged into master:

- 32485b35c929ea49a7e0785b83297669ce81cde9 by MoonlightSentinel:
  Fix Issue 20375 - std.typecons.RefCounted does not work with checkaction-context

https://github.com/dlang/dmd/pull/10550