21. これっていいの? T f(){ T t; return t; } T g(){ T t = f(); return t; } // t は NRVO される T h(){ T t = g(); return t; } // t は NRVO される … // スタック上のオブジェクト寿命を延長できてしまう
22.
23.
24.
25. Issue 5769 - struct elaborate constructor should make rvalue Issue 5178 - StructLiteral should not be lvalue struct S { this(int n){} // ref S __ctor(int n){ ...; return this; } // internally } S retval(){ return S(); } void main() { S() = S(1); // now default ctor is lvalue // StructLiteral::isLvalue() == 1 S(0) = S(1); // now user ctor is lvalue // { S tmp, tmp = S(0, 0), tmp } = S(1, 2); // internally //retval() = S(10); // fails, OK }