[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Dennis changed: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=22027 --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Steven Schveighoffer changed: What|Removed |Added Resolution|INVALID |FIXED --- Comment #15 from Steven Schveighoffer --- Fixing the resolution, as the original bug was not invalid. If I have time, I'll try to remember what this was about and open another enhancement request. --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Walter Bright changed: What|Removed |Added Status|REOPENED|RESOLVED Resolution|--- |INVALID --- Comment #14 from Walter Bright --- (In reply to Steven Schveighoffer from comment #12) > ref inout should NOT be inferred as return. inout is a pattern match > on the mutability of the parameters, it does not necessarily imply that it > is part of the return type. inout is deliberately inferred as return. It's the way the language currently works. To change it please make an enhancement request, as such should be discussed on its own merits. --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Mike Franklin changed: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=20156 --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Mike Franklin changed: What|Removed |Added CC||slavo5...@yahoo.com --- Comment #13 from Mike Franklin --- Inferring `return` on `this` for anything marked with `inout` appears to be the cause of issue 20149. --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Mike Franklin changed: What|Removed |Added See Also||https://issues.dlang.org/sh ||ow_bug.cgi?id=20149 --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Les De Ridder changed: What|Removed |Added CC||dl...@lesderid.net --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Steven Schveighoffer changed: What|Removed |Added Status|RESOLVED|REOPENED CC||schvei...@yahoo.com Resolution|FIXED |--- --- Comment #12 from Steven Schveighoffer --- (In reply to Walter Bright from comment #4) > It turns out that: > > struct String { > inout(char)* mem2() inout scope @safe { return ptr; } > char* ptr; > } > > not issuing an error is actually correct, because a parameter that is `ref > inout` is inferred to be `return`, and the `this` parameter for `mem2` is > `ref inout`. What? ref inout should NOT be inferred as return. inout is a pattern match on the mutability of the parameters, it does not necessarily imply that it is part of the return type. This can be handy when trying avoid code duplication when the const/immutable is nested under several indirections (including ref). Reopening, the original problem is not fixed. The error case added tests for compiling the functions, but doesn't test that the result of the inout function is scope (it should be). --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Atila Neves changed: What|Removed |Added CC||atila.ne...@gmail.com --- Comment #11 from Atila Neves --- I don't understand how it's possible that making it `inout` is correct inference. This allows for code that looks @safe but isn't. This really shouldn't compile: @safe: const(int)* gInt; void main() { auto s = Struct(); gInt = s.ptr; // ARGH! } struct Struct { int* ints; this(int size) { import core.stdc.stdlib; ints = () @trusted { return cast(int*) malloc(size); }(); } ~this() { import core.stdc.stdlib; () @trusted { free(ints); }(); } scope inout(int)* ptr() inout { return ints; } } And yet it does. I guess I'll have to define 3 methods for mutable, const and immutable if I want to not crash. --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 --- Comment #10 from Martin Nowak--- Thanks for investigating, so now it's reduced to the old problem that the scope system does not allow to define entry points. Of course in real life this is using malloc instead of GC'ed dup, but it's not possible to contain the former. --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 --- Comment #9 from github-bugzi...@puremagic.com --- Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3f7544f355eacc0ad390a89b1bc07ca2dbcf835e fix Issue 17927 - [scope] parameter value can be escaped via return https://github.com/dlang/dmd/commit/b46ac59c637723877b52b98ed50167e0f68aca5d Merge pull request #7235 from WalterBright/fix17927 --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 --- Comment #8 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3f7544f355eacc0ad390a89b1bc07ca2dbcf835e fix Issue 17927 - [scope] parameter value can be escaped via return https://github.com/dlang/dmd/commit/b46ac59c637723877b52b98ed50167e0f68aca5d Merge pull request #7235 from WalterBright/fix17927 fix Issue 17927 - [scope] 'scope inout' parameter value can be escaped via return --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 --- Comment #7 from Walter Bright--- Spec pull: https://github.com/dlang/dlang.org/pull/1914 --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 --- Comment #6 from Walter Bright--- https://github.com/dlang/dmd/pull/7235 --
[Issue 17927] [scope] `scope inout` parameter value can be escaped via return
https://issues.dlang.org/show_bug.cgi?id=17927 Walter Brightchanged: What|Removed |Added Summary|[scope] scope input return |[scope] `scope inout` |value can be escaped|parameter value can be ||escaped via return --