dmd/compiler/test/runnable/nrvo.d
2022-07-09 18:53:07 +02:00

30 lines
409 B
D

/***************************************************/
struct S1
{
int x;
~this() {}
}
__gshared S1* s1ptr;
S1 test1a()
{
auto result = S1(123);
(() @trusted { result.x++; s1ptr = &result; })();
return result;
}
void test1()
{
auto r = test1a();
assert(r.x == 124);
assert(&r == s1ptr);
}
/***************************************************/
void main()
{
test1();
}