8 changes: 4 additions & 4 deletions src/gc/gcbits.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ struct GCBits
{
alias size_t wordtype;

const BITS_PER_WORD = (wordtype.sizeof * 8);
const BITS_SHIFT = (wordtype.sizeof == 8 ? 6 : 5);
const BITS_MASK = (BITS_PER_WORD - 1);
const BITS_1 = cast(wordtype)1;
enum BITS_PER_WORD = (wordtype.sizeof * 8);
enum BITS_SHIFT = (wordtype.sizeof == 8 ? 6 : 5);
enum BITS_MASK = (BITS_PER_WORD - 1);
enum BITS_1 = cast(wordtype)1;

wordtype* data = null;
size_t nwords = 0; // allocated words in data[] excluding sentinals
Expand Down
16 changes: 14 additions & 2 deletions src/rt/lifetime.d
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,13 @@ extern (C) void[] _d_newarrayT(TypeInfo ti, size_t length)
}
}
else
size *= length;
{
auto newsize = size * length;
if (newsize / length != size)
goto Loverflow;

size = newsize;
}

// increase the size by the array pad.
auto info = gc_qalloc(size + __arrayPad(size), !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
Expand Down Expand Up @@ -810,7 +816,13 @@ extern (C) void[] _d_newarrayiT(TypeInfo ti, size_t length)
}
}
else
size *= length;
{
auto newsize = size * length;
if (newsize / length != size)
goto Loverflow;

size = newsize;
}

auto info = gc_qalloc(size + __arrayPad(size), !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN | BlkAttr.APPENDABLE : BlkAttr.APPENDABLE);
debug(PRINTF) printf(" p = %p\n", info.base);
Expand Down