Testing Return Value Optimization (RVO)

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Sep 28 01:15:31 PDT 2015


I tried your code as this and it doesn't work.

#!/usr/bin/rdmd -O

import std.stdio;

struct S {
     int a;
     @disable this(this);
};

S foo() {
     S v;
     v.a = 1;
     writeln(&v);
     return v;
}


void main()
{
     S x;
     x = foo();
     writeln(&x);
}

I even tried with dmd -O without success.

What am I doing wrong ?


More information about the Digitalmars-d-learn mailing list