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

           Summary: template return by reference causes seg fault
           Product: D
           Version: 2.020
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


import std.stdio;

ref T iif(T)(bool condition, ref T lhs, ref T rhs)
{
        if ( condition ) return lhs;
        return rhs;
}

ref int int_iif(bool condition, ref int lhs, ref int rhs)
{
        if ( condition ) return lhs;
        return rhs;
}

void main()
{
        int a = 10, b = 11;

        int_iif(a<b, a, b) = 42;
        writeln("a = ", a, " and b = ", b); // a = 42 and b = 11

        iif(a<b, a, b) = 52; // seg fault
        writeln("a = ", a, " and b = ", b);
}


-- 

Reply via email to