Bug 4437 – copy construction bug with "return this;"
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-07-07T15:55:00Z
Last change time
2012-04-24T18:19:32Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
andrei
Comments
Comment #0 by andrei — 2010-07-07T15:55:37Z
To reproduce, run this on Linux from the Phobos dir (after I'll check std.container in):
make unittest BUILD=debug DMDEXTRAFLAGS="-debug=RefCounted -version=bugxxxx"
where xxxx is the number of this bug. Basically in a range containing a type with an elaborate copy constructor, this works:
Range save() { auto copy = this; return copy; }
but this doesn't:
Range save() { return this; }
Comment #1 by rsinfu — 2010-09-18T14:32:47Z
Reduced test case:
-------------------- test.d
void main()
{
S s;
auto t = s.copy();
assert(t.count == 1); // (5)
}
struct S
{
int count;
this(this) { ++count; }
S copy() { return this; }
}
--------------------
% dmd -run test.d
core.exception.AssertError@test(5): Assertion failure
--------------------
Comment #2 by braddr — 2010-12-10T00:32:40Z
I'm 99% sure this is a dup of bug 3516 or together they form the basis of a more general ticket: structs and their postblit and dtors are just mostly unimplmented.