Skip to content

Commit

Permalink
Fix Issue 6436 - Refcounted initialization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-sh committed Oct 27, 2012
1 parent 4bc2194 commit dab3b2a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions std/typecons.d
Expand Up @@ -2478,7 +2478,7 @@ if (!is(T == class))

private Impl* _store;

private void initialize(A...)(A args)
private void initialize(A...)(auto ref A args)
{
_store = cast(Impl*) enforce(malloc(Impl.sizeof));
if (hasIndirections!T)
Expand Down Expand Up @@ -2533,7 +2533,7 @@ Constructor that initializes the payload.
Postcondition: $(D refCountedIsInitialized)
*/
this(A...)(A args) if (A.length > 0)
this(A...)(auto ref A args) if (A.length > 0)
{
_refCounted.initialize(args);
}
Expand Down Expand Up @@ -2704,6 +2704,16 @@ unittest
alias RefCounted!S SRC;
}

// 6436
unittest
{
struct S { this(ref int val) { assert(val == 3); ++val; } }

int val = 3;
auto s = RefCounted!S(val);
assert(val == 4);
}

unittest
{
RefCounted!int a;
Expand Down

0 comments on commit dab3b2a

Please sign in to comment.