digitalmars.D.bugs - [Issue 12444] New: std.array uninitializedArray & minimallyInitializedArray missing APPENDABLE attribute / capacity info
- d-bugmail puremagic.com (46/46) Mar 23 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12444
- d-bugmail puremagic.com (10/10) Mar 23 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12444
- d-bugmail puremagic.com (9/9) Mar 24 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12444
- d-bugmail puremagic.com (28/28) Mar 24 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12444
https://d.puremagic.com/issues/show_bug.cgi?id=12444 Summary: std.array uninitializedArray & minimallyInitializedArray missing APPENDABLE attribute / capacity info Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: safety0ff.bugz gmail.com 03:48:59 PDT --- import std.array; import std.stdio; import core.memory; void main() { double[] a = uninitializedArray!(double[])(100); a = a[0 .. 1]; assert(a.capacity == 0); a.assumeSafeAppend(); assert(a.capacity != 0); // Error double[] b = minimallyInitializedArray!(double[])(100); b = b[0 .. 1]; assert(b.capacity == 0); b.assumeSafeAppend(); assert(b.capacity != 0); // Error double[] c = new double[100]; c = c[0 .. 1]; assert(c.capacity == 0); c.assumeSafeAppend(); assert(c.capacity != 0); // OK! auto dptr = cast(double*)GC.malloc(100 * double.sizeof, GC.BlkAttr.NO_SCAN | GC.BlkAttr.APPENDABLE); double[] d = dptr[0 .. 100]; d = d[0 .. 1]; assert(d.capacity == 0); d.assumeSafeAppend(); assert(d.capacity != 0); // OK! } -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12444 safety0ff.bugz <safety0ff.bugz gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull 21:30:08 PDT --- https://github.com/D-Programming-Language/phobos/pull/2044 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 23 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12444 safety0ff.bugz <safety0ff.bugz gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 24 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12444 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |monarchdodra gmail.com Resolution|INVALID | Just to be clear, this issue is NOT invalid. It's just that your proposed solution doesn't work. An implementation that could work is: T[] uninitializedArray(T)(size_t n) { T[] buff; //Declare buff. //Use the GC to do an Appendable allocation buff.reserve(n); //Slice out of bounds.... buff = buff.ptr[0 .. n]; //And tell the GC what the actual new bounds are. buff = assumeSafeAppend(buff); return buff; } This could not work up until now, because `assumeSafeAppend` was not nothrow. It's not nothrow anymore, but it's not yet pure either, so it still isn't useable. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 24 2014