Skip to content

Commit 7a6650b

Browse files
authored
Fix expanding array with implicitly non-copyable types (dlang/dmd!21846)
Fix dlang/dmd#21832
1 parent 5e97125 commit 7a6650b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

runtime/druntime/src/core/internal/array/capacity.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ private size_t _d_arraysetlengthT_(Tarr : T[], T)(return ref scope Tarr arr, siz
254254
}
255255

256256
enum sizeelem = T.sizeof;
257-
enum hasPostblit = __traits(hasMember, T, "__postblit");
258-
enum hasEnabledPostblit = hasPostblit && !__traits(isDisabled, T.__postblit);
257+
enum hasPostblit = __traits(hasMember, T, "__xpostblit");
258+
enum hasEnabledPostblit = hasPostblit && !__traits(isDisabled, T.__xpostblit);
259259

260260
bool overflow = false;
261261
const newsize = mulu(sizeelem, newlength, overflow);

tests/dmd/compilable/test21835.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://github.com/dlang/dmd/issues/21832
2+
// resize array of implicitly non-copyable items
3+
4+
void bugGH21832()
5+
{
6+
static struct S { @disable this(this); }
7+
static struct Item { S s; }
8+
9+
Item[] arr;
10+
arr.length++;
11+
}

0 commit comments

Comments
 (0)