"Error: address of variable this assigned to this with longer lifetime"

Nathan S. no.public.email at example.com
Tue Mar 13 21:35:50 UTC 2018


On Tuesday, 13 March 2018 at 21:07:33 UTC, ag0aep6g wrote:
> You're storing a reference to `small` in `data`. When a 
> SmallString is copied, that reference will still point to the 
> original `small`. When the original goes out of scope, the 
> reference becomes invalid, a dangling pointer. Can't have those 
> in @safe code.
>
> The error message isn't exactly clear, though.

The error does not go away when restoring these lines:

```
     @disable this(this);
     @disable void opAssign(this);
```


More information about the Digitalmars-d-learn mailing list