[Issue 6436] Refcounted initialization bug

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 19 18:45:00 PDT 2012


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



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-04-19 18:45:56 PDT ---
Interestingly if you pass by pointer instead of by ref it works fine. Here's a
much more simplified example:

import std.typecons;
import std.stdio;

struct Struct1 {
    this(ref int val) { val = 5; }
}

struct Struct2 {
    this(int* val) { *val = 5; }
}

alias RefCounted!(Struct1) Str1;
alias RefCounted!(Struct2) Str2;

void main()
{
    Str1 str1;
    Str2 str2;
    int val;

    str1 = Str1(val);
    writeln(val);  // writes 0

    str2 = Str2(&val);
    writeln(val);  // writes 5    
}

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