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


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Don <clugd...@yahoo.com.au> 2009-12-30 13:11:55 PST ---
Shouldn't be doing no-side-effect calls if there's a hidden parameter.
This happens if the value is being returned on the stack.

PATCH (e2ir.c line 287):

    else if (ep)
-    e = el_bin((tf->ispure && tf->isnothrow) ? OPcallns : OPcall,tyret,ec,ep);
+    e = el_bin((tf->ispure && tf->isnothrow && (retmethod != RETstack)) ?
OPcallns : OPcall,tyret,ec,ep);
    else
-    e = el_una((tf->ispure && tf->isnothrow) ? OPucallns : OPucall,tyret,ec);
+    e = el_una((tf->ispure && tf->isnothrow && (retmethod != RETstack)) ?
OPucallns : OPucall,tyret,ec);

-------
TEST CASE:

struct Foo {
    int x, y;
    real z;
}

pure nothrow Foo makeFoo(const int x, const int y) {
    return Foo(x, y, 3.0);
}


void main()
{
    auto f = makeFoo(1, 2);
   assert(f.x==1);
   assert(f.y==2);
   assert(f.z==3);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to