Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
May 25, 2009 [Issue 3024] New: array slicing bypass the stack var escape check | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=3024 Summary: array slicing bypass the stack var escape check Product: D Version: 2.028 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: davidl@126.com import std.stdio; string func() { string s="abc"; return s; } void func1() { writefln("func1"); string v = func(); writefln("call func"); writefln(func2()); } byte[] func2() { writefln("hello!"); byte[16] v= [65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65]; writefln(v[0..16]); return v[0..16]; } void main(string[] args) { func1(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 25, 2009 [Issue 3024] array slicing bypass the stack var escape check | ||||
---|---|---|---|---|
| ||||
Posted in reply to davidl@126.com | http://d.puremagic.com/issues/show_bug.cgi?id=3024 Koroskin Denis <2korden@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |2korden@gmail.com Severity|normal |enhancement --- Comment #1 from Koroskin Denis <2korden@gmail.com> 2009-05-25 06:45:13 PDT --- It is exactly the same as byte[] tmp = v[0..16]; return tmp; Compiler can't detect operations like this ATM, and is not supposed to (according to specs). Marking it as an enhancement request, I wouldn't hold my breath for this being fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 12, 2009 [Issue 3024] Array slicing allows returning an escaping reference to a local stack variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to davidl@126.com | http://d.puremagic.com/issues/show_bug.cgi?id=3024 Matti Niemenmaa <matti.niemenmaa+dbugzilla@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Platform|x86 |All Version|2.028 |1.045 Summary|array slicing bypass the |Array slicing allows |stack var escape check |returning an escaping | |reference to a local stack | |variable OS/Version|Windows |All --- Comment #2 from Matti Niemenmaa <matti.niemenmaa+dbugzilla@iki.fi> 2009-07-12 08:53:14 PDT --- Also affects 1.0. It's true that the specs don't mention it but it's a bit inconsistent that both the pointer and scope object cases are detected while the case of array slicing isn't. Of the following, currently only the first three result in a compile error: int* pointer() { int x; return &x; } Object object() { scope Object x; return x; } int[] array() { int[1] x; return x; } int[] slice() { int[1] x; return x[]; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation