[Issue 3270] pure functions returning struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 30 13:11:57 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3270
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #2 from Don <clugdbug at 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: -------
More information about the Digitalmars-d-bugs
mailing list