__rvalue and Move Semantics first draft - aliasing problem/danger
Walter Bright
newshound2 at digitalmars.com
Sat Nov 9 22:44:28 UTC 2024
I'm not sure it's a problem or a danger.
Timon mentioned the related problem with:
```
callee(__rvalue s, __rvalue s);
```
where s would be destroyed twice. This isn't always detectable:
```
S* ps = ...;
callee(__rvalue *s, __rvalue(*s));
```
But can be rendered benign with the blit of S.init after the destructor call.
On 11/9/2024 6:32 AM, kinke wrote:
> Wrt. safety, I think we should at least also mention the aliasing problem/danger:
> ```D
> void callee(ref S x, S y) {
> assert(&x != &y);
> }
>
> void caller() {
> S lval;
> callee(lval, __rvalue(lval));
> }
> ```
More information about the dip.development
mailing list