[Issue 12444] New: std.array uninitializedArray & minimallyInitializedArray missing APPENDABLE attribute / capacity info
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 23 03:49:00 PDT 2014
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 at puremagic.com
ReportedBy: safety0ff.bugz at gmail.com
--- Comment #0 from safety0ff.bugz <safety0ff.bugz at gmail.com> 2014-03-23 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: -------
More information about the Digitalmars-d-bugs
mailing list