On Saturday, 9 November 2024 at 22:39:33 UTC, Walter Bright wrote:
>I suggest the most pragmatic implementation of your ideas is to append to the destructor calls to rvalue parameters a blit of the .init value. It is only necessary if the rvalue has a destructor. The callee cannot know if an rvalue was passed using __rvalue, so it has to defensively do this anyway.
I'm not too fond of that, as that means doing the blit for every value parameter with a dtor, not just in the (presumably way less) call sites using __rvalue
. Adding a cleanup-scope (finally
) for the call shouldn't be too hard, reset-blitting all arguments that were __rvalue'd. Incl. PODs and non-PODs without dtor, to get the T.init
-state guarantee in all cases, required to make this feature half-way safe in cases where the compiler cannot prove that the original lvalue isn't accessed later.