On Mon, 06 May 2013 09:43:38 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
ref int min(ref int a, ref int b) { return b < a ? b : a; }
...
int x;
fun(min(x, 100));
Here the result of min may be bound to an lvalue or an rvalue depending
on a condition. In the latter case, combined with D's propensity to
destroy temporaries too early (immediately after function calls), the
behavior is silently undefined; the code may pass unittests.
Focusing back on this, I think any rvalues should be treated as though
they survive through the end of the statement. If the compiler can prove
they are not in use after partially executing a statement, they can be
destroyed early.
Is there any reason this shouldn't be the case?
-Steve