[Issue 10146] ref on return is ignored
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 23 04:08:44 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10146
--- Comment #2 from rswhite4 at googlemail.com 2013-05-23 04:08:43 PDT ---
I expected that in this case opAssign is called, not the postblit, beause I
return by ref and assign then the ref to a new value.
But if you change A to this:
[code]
struct A {
public:
int id;
this(int id) {
writeln("CTor ", id);
this.id = id;
}
this(this) {
writeln("Postblit ", this.id);
this.id *= 2;
}
void opAssign(ref const A a) {
writeln("opAssign L: ", a.id);
this.id = a.id;
}
void opAssign(const A a) {
writeln("opAssign R ", a.id);
memcpy(&this, &a, A.sizeof);
}
~this() {
writeln("DTor ", this.id);
}
}
[/code]
You see still the same output, no call of opAssign by 'getA':
----
CTor 42
opAssign R 42
DTor 42
Return A
Postblit 42
DTor 84
DTor 42
----
Or did I miss something important here?
--
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