Thread overview
[Issue 22309] Taking the address of a stack variable struct with this is wrongly seen as @safe
Sep 15, 2021
Dlang Bot
Sep 15, 2021
João Lourenço
Mar 28, 2022
Dennis
September 15, 2021
https://issues.dlang.org/show_bug.cgi?id=22309

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@iK4tsu created dlang/dmd pull request #13074 "Fix Issue 22309 - Taking the address of a stack variable struct with this is wrongly seen as @safe" fixing this issue:

- dmd.expressionsem: fix taking address of this in safe code

  FIX ISSUE #22309

  Signed-off-by: João Lourenço <jlourenco5691@gmail.com>

https://github.com/dlang/dmd/pull/13074

--
September 15, 2021
https://issues.dlang.org/show_bug.cgi?id=22309

João Lourenço <jlourenco5691@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlourenco5691@gmail.com
           Severity|enhancement                 |normal

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

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dkorpel@live.nl
           Hardware|x86_64                      |All
         Resolution|---                         |FIXED
                 OS|Linux                       |All

--- Comment #2 from Dennis <dkorpel@live.nl> ---
As mentioned in the Pull Request discussion, this has to be covered by dip1000.
As of https://github.com/dlang/dmd/pull/13672, the code is rejected with
-preview=dip1000:
```
test_.d(4): Error: reference to local variable `this` assigned to non-scope
parameter `foo` calling test_.Bar.this
test_.d(21): Error: reference to local variable `foo` assigned to non-scope
parameter `foo` calling test_.Bar.this
```

--