You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an array slice starts from a GC allocated block that is *not* marked appendable, the appendable flag never gets set until appending occurs.
example:
```dstruct S{ int[1] val;}void main(){ auto s = new S; int[] arr = s.val[]; assert(arr.capacity == 0); // starts out without appendability arr.length = 2; assert(arr.capacity > 0); // this fails arr.reserve(100); assert(arr.capacity > 0); // this fails arr ~= 10; assert(arr.capacity > 0); // finally, this succeeds}```
The issue is that the `__arrayAlloc` function copies the original bits instead of using the typeinfo to decide the new array bits if a BlkInfo has already been looked up. I guess the thought is that using the TypeInfo to build the bits is more expensive, and we "already have something".
Options are to just always use the typeinfo, or to check for the appendable bit before using the old bits (but copying the other bits might be questionable as well).
The text was updated successfully, but these errors were encountered:
Steven Schveighoffer (@schveiguy) reported this on 2024-06-18T11:56:09Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24617
Description
The text was updated successfully, but these errors were encountered: