[Issue 19812] Lambda over struct member causes dangling reference to out-of-scope struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 14 07:25:11 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=19812
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla at digitalmars.com
--- Comment #4 from Walter Bright <bugzilla at 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`
> }
--
More information about the Digitalmars-d-bugs
mailing list