[Issue 2448] New: template return by reference causes seg fault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 11 10:06:39 PST 2008


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: bugzilla at digitalmars.com
        ReportedBy: k-foley at onu.edu


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);
}


-- 



More information about the Digitalmars-d-bugs mailing list