Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/object.d
Original file line number Diff line number Diff line change
Expand Up @@ -3491,7 +3491,7 @@ private U[] _dup(T, U)(scope T[] a) pure nothrow @trusted if (__traits(isPOD, T)
return *cast(U[]*) &arr;
}

private U[] _dupCtfe(T, U)(T[] a)
private U[] _dupCtfe(T, U)(scope T[] a)
{
static if (is(T : void))
assert(0, "Cannot dup a void[] array at compile time.");
Expand Down Expand Up @@ -3524,6 +3524,21 @@ private U[] _dup(T, U)(T[] a) if (!__traits(isPOD, T))
return res;
}

// https://issues.dlang.org/show_bug.cgi?id=22107
@safe unittest
{
static int i;
@safe struct S
{
this(this) { i++; }
}

void fun(scope S[] values...) @safe
{
values.dup;
}
}

// HACK: This is a lie. `_d_arraysetcapacity` is neither `nothrow` nor `pure`, but this lie is
// necessary for now to prevent breaking code.
private extern (C) size_t _d_arraysetcapacity(const TypeInfo ti, size_t newcapacity, void[]* arrptr) pure nothrow;
Expand Down