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

2018-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 14, 2018 07:11:49 Nathan S. via Digitalmars-d-learn wrote: > On Tuesday, 13 March 2018 at 22:33:56 UTC, Jonathan M Davis wrote: > > And you can't get rid of it, because the object can still be > > moved, which would invalidate the pointer that you have > > referring to the stat

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

2018-03-14 Thread Nathan S. via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 22:33:56 UTC, Jonathan M Davis wrote: And you can't get rid of it, because the object can still be moved, which would invalidate the pointer that you have referring to the static array. ... https://issues.dlang.org/show_bug.cgi?id=17448 Thanks for the info.

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

2018-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 13, 2018 21:35:50 Nathan S. via Digitalmars-d-learn wrote: > 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 orig

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

2018-03-13 Thread Nathan S. via Digitalmars-d-learn
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 t

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

2018-03-13 Thread ag0aep6g via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 20:49:16 UTC, Nathan S. wrote: "onlineapp.d(16): Error: address of variable this assigned to this with longer lifetime" ```d [...] struct SmallString { char[24] small; char[] data; [...] this(scope const(char)[

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

2018-03-13 Thread Nathan S. via Digitalmars-d-learn
What is this malarky? https://run.dlang.io/is/S42EBb "onlineapp.d(16): Error: address of variable this assigned to this with longer lifetime" ```d import std.stdio; struct SmallString { char[24] small; char[] data; @disable this(); this(scope const(char)[