[Issue 17897] Postblit is not called for temporary structures in the function parameters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 13 13:33:25 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17897

--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> ---
Sorry, I didn't mean to commit so early.

A postblit is not called for a move, which is done for rvalues being sent into
a function:

import std.stdio;
struct S
{
   this(this) { writeln("postblit"); }
}

void foo(S s)
{
}

void main()
{
   foo(S()); // no postblit, this is an rvalue. The struct isn't actually moved
anyway.
   S s;
   foo(s); // postblit called, because we made a copy of s onto the stack to
send into foo.
}

--


More information about the Digitalmars-d-bugs mailing list