[Issue 10146] New: ref on return is ignored
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 23 03:42:35 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10146
Summary: ref on return is ignored
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: rswhite4 at googlemail.com
--- Comment #0 from rswhite4 at googlemail.com 2013-05-23 03:42:34 PDT ---
The 'ref' by 'getA' is ignored.
[code]
import std.stdio;
struct A {
public:
int id;
this(int id) {
writeln("CTor ", id);
this.id = id;
}
this(this) {
writeln("Postblit ", this.id);
this.id *= 2;
}
~this() {
writeln("DTor ", this.id);
}
}
class B {
private:
A _a;
public:
this() {
this._a = A(42);
}
ref A getA() {
writeln("Return A");
return this._a;
}
}
void main() {
B b = new B();
A a = b.getA();
}
[/code]
Expected Output:
----
CTor 42
DTor 0
Return A
DTor 42
----
Current Output:
----
CTor 42
DTor 0
Return A
Postblit 42
DTor 84
DTor 42
----
--
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