Jump to page: 1 2
Thread overview
[Issue 19812] nested class reference causes dangling reference to out-of-scope struct
[Issue 19812] Lambda over struct member causes dangling reference to out-of-scope struct
Apr 22, 2019
Radu Racariu
Jun 04, 2019
Dlang Bot
Jun 04, 2019
Dlang Bot
Aug 14, 2022
Walter Bright
Aug 14, 2022
Walter Bright
Aug 14, 2022
Walter Bright
Aug 14, 2022
Dlang Bot
Aug 31, 2022
Dlang Bot
Sep 21, 2022
Iain Buclaw
Sep 21, 2022
Iain Buclaw
Sep 21, 2022
Iain Buclaw
Sep 27, 2022
Dlang Bot
Dec 17, 2022
Iain Buclaw
April 22, 2019
https://issues.dlang.org/show_bug.cgi?id=19812

Radu Racariu <radu.racariu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |radu.racariu@gmail.com

--
June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19812

Suleyman Sahmi (سليمان السهمي) <sahmi.soulaimane@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sahmi.soulaimane@gmail.com

--- Comment #1 from Suleyman Sahmi (سليمان السهمي) <sahmi.soulaimane@gmail.com> ---
Another similar case

```
auto makeI(int m) @safe
{
    static struct S
    {
        int m;
        auto inner()
        {
            class I
            {
                auto get() @safe { return m; }
            }
            return new I;
        }
    }
    scope s = S(m);
    return s.inner();
}

void main() @safe
{
    auto i = makeI(5);

    function()
    {
        // clean stack
        pragma(inline, false);
        long[0x500] a = 0;
    }();

    assert(i.get() == 5);
}
```

https://run.dlang.io/is/xhzYPo

--
June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19812

Suleyman Sahmi (سليمان السهمي) <sahmi.soulaimane@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major

--
June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19812

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@SSoulaimane created dlang/dmd pull request #9966 "Fix test case - escaping reference to stack struct" mentioning this issue:

- issue 19812 - Fix test case, escaping reference to stack struct
  DMD should catch this

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

--
June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19812

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #9966 "Fix test case - escaping reference to stack struct" was merged into master:

- e62e6e6f68d85682f6a7f664ede871069ec43e12 by سليمان السهمي  (Suleyman Sahmi):
  issue 19812 - Fix test case, escaping reference to stack struct
  DMD should catch this

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

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

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Suleyman Sahmi (سليمان السهمي) from comment #1)
> Another similar case
> 
> ```
> auto makeI(int m) @safe
> {
>     static struct S
>     {
>         int m;
>         auto inner() // adding `return` attribute here
>         {
>             class I
>             {
>                 auto get() @safe { return m; }
>             }
>             return new I;
>         }
>     }
>     scope s = S(m);
>     return s.inner(); // causes correct error returning `s.inner()` escapes a reference to local variable `s`
> }

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

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
The fix appears to be in the `return` inference for auto functions. It should look for returning an instance of a nested class.

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

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Lambda over struct member   |nested class reference
                   |causes dangling reference   |causes dangling reference
                   |to out-of-scope struct      |to out-of-scope struct

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

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

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

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #14367 "fix Issue 19812 - nested class reference causes dangling reference to…" fixing this issue:

- fix Issue 19812 - nested class reference causes dangling reference to out-of-scope struct

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

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14367 "fix Issue 19812 - nested class reference causes dangling reference to…" was merged into master:

- 578432b86766890e7383ffd3f3e1ae51e226c49f by Walter Bright:
  fix Issue 19812 - nested class reference causes dangling reference to
out-of-scope struct

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

--
« First   ‹ Prev
1 2