Persistent list
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Sun Nov 15 07:20:22 PST 2015
On Sunday, 15 November 2015 at 15:09:25 UTC, Jonathan M Davis
wrote:
> After the call to bar, the compiler can guarantee that the
> value of foo has not changed, because it's not possible for bar
> to access foo except via a const reference, and it can clearly
> see that, because it can see that it's not possible for bar to
> access foo except via the reference that's passed to it.
Note that it can only do so if escape analysis is able to prove
no other reference escapes to the same data. Otherwise it can be
mutated even during that function call in other thread. All
together it makes benefits of such deduction absolutely not worth
UB limitation in my opinion.
For pure functions it is quite different story though and I agree
that demanding it to be UB there is totally legitimate.
More information about the Digitalmars-d
mailing list