www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - rvalues as ref arguments

reply bearophile <bearophileHUGS lycos.com> writes:
This code doesn't work in DMD 1.046 anymore (I think it may work in DMD 1.045
and it works for sure in DMD 1.042):

struct V {
    int x;
    V opAdd(V v) { return V.init; }
}
void foo(ref V v) {}
void main() {
    foo(V.init + V.init);
}

On IRC the gentle Daniel Keep has told me this seems an undocumented change.
Both LDC and my code may need to change a bit for this.

Bye,
bearophile
Aug 02 2009
parent Jarrett Billingsley <jarrett.billingsley gmail.com> writes:
On Sun, Aug 2, 2009 at 10:51 AM, bearophile<bearophileHUGS lycos.com> wrote=
:
 This code doesn't work in DMD 1.046 anymore (I think it may work in DMD 1=
.045 and it works for sure in DMD 1.042):
 struct V {
 =A0 =A0int x;
 =A0 =A0V opAdd(V v) { return V.init; }
 }
 void foo(ref V v) {}
 void main() {
 =A0 =A0foo(V.init + V.init);
 }

 On IRC the gentle Daniel Keep has told me this seems an undocumented chan=
ge. Both LDC and my code may need to change a bit for this. It's already been reported. http://d.puremagic.com/issues/show_bug.cgi?id=3D3167
Aug 02 2009