Thread overview
[Issue 22522] [dip1000] Creating interior pointers allowed in @safe
Feb 13, 2022
Florian Weimer
Feb 13, 2022
Florian Weimer
Feb 13, 2022
Dennis
Feb 17, 2022
Walter Bright
Mar 03, 2022
Dennis
Aug 15, 2022
Walter Bright
Aug 15, 2022
Dennis
Aug 15, 2022
Dennis
Dec 17, 2022
Iain Buclaw
February 13, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

Florian Weimer <fw@deneb.enyo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fw@deneb.enyo.de

--
February 13, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

--- Comment #1 from Florian Weimer <fw@deneb.enyo.de> ---
I get an error for this with dmd as of commit 05a27e287e546e8553741fffccea0059f0c11f63:

t.d(8): Error: address of variable `this` assigned to `this` with longer
lifetime

--
February 13, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

--- Comment #2 from Dennis <dkorpel@live.nl> ---
(In reply to Florian Weimer from comment #1)
> I get an error for this with dmd as of commit 05a27e287e546e8553741fffccea0059f0c11f63:
> 
> t.d(8): Error: address of variable `this` assigned to `this` with longer
> lifetime

I think this was fixed by https://github.com/dlang/dmd/pull/13577 then

--
February 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|---                         |WORKSFORME

--
March 03, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---

--- Comment #3 from Dennis <dkorpel@live.nl> ---
Re-opening, because:
- the error message makes no sense
- this is not yet tested for in the test suite
- hence, the accidental 'fix' will quietly be reverted when issue 22801 gets
fixed

--
August 15, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
The error message isn't great, but it is correctly identifying the problem.

    ptr = &storage;

*is* taking the address of `this`, and assigning it to `this`.

As in`storage` is *(this+0), and `ptr` is *(this+8)

--
August 15, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |---

--- Comment #5 from Dennis <dkorpel@live.nl> ---
(In reply to Walter Bright from comment #4)
> The error message isn't great, but it is correctly identifying the problem.

It's saying `this` has longer lifetime than `this`. Since when does `x > x` evaluate to true?

It also still works when you add `return scope` to the constructor:
```
@safe:
struct S {
    int storage;
    int* ptr;

    this(int dummy) return scope {
        ptr = &storage;
    }

    int* get() return scope {
        return ptr;
    }
}

int* escape() {
    S s = S(0);
    return s.get; // escapes a pointer to stack variable `s`
}
```

--
August 15, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

--- Comment #6 from Dennis <dkorpel@live.nl> ---
(In reply to Dennis from comment #5)
> It's saying `this` has longer lifetime than `this`. Since when does `x > x` evaluate to true?

Nevermind, it says `this` has longer lifetime than "address of variable `this`", but, it should be in test suite and the modification with `return scope` needs to error.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=22522

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=22522

--- Comment #7 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18066

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--