|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.bugs - [Issue 2075] New: Spec does not specify how array literals are stored.
http://d.puremagic.com/issues/show_bug.cgi?id=2075 Summary: Spec does not specify how array literals are stored. Product: D Version: 1.029 Platform: PC OS/Version: Linux Status: NEW Keywords: spec Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: tomas famolsen.dk It seems DMD currently allocates all array literals on the GC heap. The spec however does not state that this is the required behaviour, and frankly I think it's a bad idea not being able to get a stack array without instead declaring a static array temporary explicitly. -- May 06 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2075 ------- Comment #1 from tomas famolsen.dk 2008-05-06 15:04 ------- Code to see for yourself: extern(C) int printf(char*, ...); int[] func() { int[] arr = [1,2,3]; return arr; } void main() { int stack; int[] arr = func(); printf("%d %d %d\n", arr[0], arr[1], arr[2]); printf("stack: %p\nwhere? %p\n", &stack, arr.ptr); int[] arr2 = [1,2,3,4,5]; printf("where? %p\n", arr2.ptr); } -- May 06 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2075 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla digitalmars.com 2008-05-22 05:05 ------- Fixed dmd 1.030 and 2.014 -- May 22 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2075 brunodomedeiros+bugz gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |brunodomedeiros+bugz gmail.c | |om ------- Comment #3 from brunodomedeiros+bugz gmail.com 2008-05-28 16:13 ------- It might also be good to state that each array literal evaluation causes a new array to be allocated. (Unlike string literals for example) -- May 28 2008
|