Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 06, 2018 [Issue 18738] [scope] scope delegates can be escaped via closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18738 ag0aep6g <ag0aep6g@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |safe CC| |ag0aep6g@gmail.com Hardware|x86_64 |All OS|Linux |All -- |
April 21, 2018 [Issue 18738] [scope] scope delegates can be escaped via closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18738 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #1 from Nick Treleaven <nick@geany.org> --- Closures don't seem to be checked for scope pointers at all: @safe: void delegate() foo(ref int a) { return { a++; }; } void delegate() bar() { int a; return foo(a); // leaking reference to `a` } -- |
December 06, 2022 [Issue 18738] [scope] scope delegates can be escaped via closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18738 andy.pj.hanson@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andy.pj.hanson@gmail.com --- Comment #2 from andy.pj.hanson@gmail.com --- I think is a similar bug: ``` @safe: import std.stdio : writeln; void main() { int* x = escape(); writeln("x is ", *x); // x is 1 *x = 5; escape(); writeln("x is ", *x); // x is 1 } pure @nogc nothrow: int* escape() { int* res; callbackWithPointer([1, 2, 3], (int* i) { res = i; }); return res; } void callbackWithPointer(T)(scope T[] a, scope void delegate(T*) @safe @nogc pure nothrow f) { f(&a[0]); } ``` In this case a `pure` function `escape` appears to return a pointer to global state. `f(&a[0])` probably shouldn't be allowed. The delegate expects a `T*` but gets a `scope T*`. -- |
December 17, 2022 [Issue 18738] [scope] scope delegates can be escaped via closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18738 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
December 13 [Issue 18738] [scope] scope delegates can be escaped via closure | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=18738 --- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17855 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation