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.

      • Re: DIP1000 ag0aep6g via Digitalmars-d-learn
        • Re: DIP1000 Ola Fosheim Grøstad via Digitalmars-d-learn
        • Re: DIP1000 Ola Fosheim Grøstad via Digitalmars-d-learn
          • Re: DIP1000 Paul Backus via Digitalmars-d-learn
            • Re: DIP... Ola Fosheim Grøstad via Digitalmars-d-learn
              • Re:... Dukc via Digitalmars-d-learn
              • Re:... Ola Fosheim Grøstad via Digitalmars-d-learn
  • Re: DIP1000 Loara via Digitalmars-d-learn
    • Re: DIP1000 Ola Fosheim Grøstad via Digitalmars-d-learn
      • Re: DIP1000 Loara via Digitalmars-d-learn
        • Re: DIP1000 Ola Fosheim Grøstad via Digitalmars-d-learn
          • Re: DIP1000 bauss via Digitalmars-d-learn
            • Re: DIP... Ola Fosheim Grøstad via Digitalmars-d-learn
          • Re: DIP1000 Loara via Digitalmars-d-learn
            • Re: DIP... Ola Fosheim Grøstad via Digitalmars-d-learn
              • Re:... Loara via Digitalmars-d-learn
              • Re:... Ola Fosheim Grøstad via Digitalmars-d-learn

Reply via email to