DIP1000
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Tue Jun 28 21:58:48 UTC 2022
On Tuesday, 28 June 2022 at 21:40:44 UTC, Loara wrote:
> When `connect()` returns may happen that `b` is destroyed but
> `a` not, so `a.next` contains a dangling pointer that
Not when connect returns, but the scope that connect was called
from. Still, this can be deduced, you just have to give the
scopes an ordering.
> not-scoped variable (`a.next` is not `scope` since this
> attribute is not transitive)
Well, that is a flaw, if the object is stack allocated then the
fields are too.
> is clearly dangerous since `connect` doesn't know which between
> `a` and `b` terminates first.
The compiler could easily deduce it. It is not difficult to see
what the life time constraint must be.
More information about the Digitalmars-d-learn
mailing list