summaryrefslogtreecommitdiff
path: root/libphobos/libdruntime/core/lifetime.d
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2022-04-29 17:54:39 +0100
committerIain Sandoe <iain@sandoe.co.uk>2022-04-29 17:54:39 +0100
commit3e5f7ca352c26a222bb588741b7c700a3052a372 (patch)
tree283aec084274668fe34c23c49ab2999390ed9778 /libphobos/libdruntime/core/lifetime.d
parent2ce0608ca3dca30518bec525c435f7bc4d7f9b70 (diff)
parentb85e79dce149df68b92ef63ca2a40ff1dfa61396 (diff)
downloadgcc-3e5f7ca352c26a222bb588741b7c700a3052a372.tar.gz
Merge master r12-8312.devel/c++-coroutines
* Merge master r12-8312-gb85e79dce149.
Diffstat (limited to 'libphobos/libdruntime/core/lifetime.d')
-rw-r--r--libphobos/libdruntime/core/lifetime.d20
1 files changed, 19 insertions, 1 deletions
diff --git a/libphobos/libdruntime/core/lifetime.d b/libphobos/libdruntime/core/lifetime.d
index 3a7c8e02b8a..47fed9dc514 100644
--- a/libphobos/libdruntime/core/lifetime.d
+++ b/libphobos/libdruntime/core/lifetime.d
@@ -1273,7 +1273,9 @@ void copyEmplace(S, T)(ref S source, ref T target) @system
}
else static if (__traits(hasCopyConstructor, T))
{
- emplace(cast(Unqual!(T)*) &target); // blit T.init
+ // https://issues.dlang.org/show_bug.cgi?id=22766
+ import core.internal.lifetime : emplaceInitializer;
+ emplaceInitializer(*(cast(Unqual!T*)&target));
static if (__traits(isNested, T))
{
// copy context pointer
@@ -1373,6 +1375,22 @@ void copyEmplace(S, T)(ref S source, ref T target) @system
static assert(!__traits(compiles, copyEmplace(ss, t)));
}
+// https://issues.dlang.org/show_bug.cgi?id=22766
+@system pure nothrow @nogc unittest
+{
+ static struct S
+ {
+ @disable this();
+ this(int) @safe pure nothrow @nogc{}
+ this(ref const(S) other) @safe pure nothrow @nogc {}
+ }
+
+ S s1 = S(1);
+ S s2 = void;
+ copyEmplace(s1, s2);
+ assert(s2 == S(1));
+}
+
version (DigitalMars) version (X86) version (Posix) version = DMD_X86_Posix;
// don't violate immutability for reference types