Skip to content

Commit

Permalink
Fix Bugzilla 15315 - can break immutable with std.algorithm.move
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel committed Jul 27, 2024
1 parent c00a5ee commit 6ef8955
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,16 @@ pure nothrow @safe @nogc unittest
assert(s53 is s51);
}

unittest
{
static struct S
{
immutable int i;
~this() @safe {}
}
static assert(!__traits(compiles, { S a, b; move(a, b); }));
}

/// Ditto
T move(T)(return scope ref T source)
{
Expand Down Expand Up @@ -1414,6 +1424,7 @@ private T trustedMoveImpl(T)(ref return scope T source) @trusted
}

private void moveEmplaceImpl(T)(ref scope T target, ref return scope T source)
if (__traits(compiles, target = T.init))
{
import core.stdc.string : memcpy, memset;
import std.traits : hasAliasing, hasElaborateAssign,
Expand Down

0 comments on commit 6ef8955

Please sign in to comment.