digitalmars.D.bugs - [Issue 9270] New: Undetected ref escape of local slice
- d-bugmail puremagic.com (33/33) Jan 05 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9270
- d-bugmail puremagic.com (12/12) Jan 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9270
http://d.puremagic.com/issues/show_bug.cgi?id=9270 Summary: Undetected ref escape of local slice Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc (This is a borderline enhancement request.) ref int[] foo() { static int[5] data; return data[0 .. 4]; } void main() { import std.stdio; writeln(foo().length); } This program compiles with no errors or warnings (dmd 2.061), but it's wrong code, because the data slice local to foo() gets lost when the stack frame of foo() is popped out of the stack. Compiling that program with "-O" prints something like: 1635172 So in this case I suggest to generate a escape local variable error at compile time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 05 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9270 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies gmail.com Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 2486 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 06 2013