From baad665621e244628f7b78eb56a21ffa07253ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 10 Oct 2016 11:16:55 +0200 Subject: [PATCH] Work around stricter memory-safety checks in DMD 2.072.0-b2. --- source/taggedalgebraic.d | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source/taggedalgebraic.d b/source/taggedalgebraic.d index ffaac49..5b1112c 100644 --- a/source/taggedalgebraic.d +++ b/source/taggedalgebraic.d @@ -277,7 +277,7 @@ unittest alias TA = TaggedAlgebraic!Test; - TA ta; + TA ta = null; // FIXME: should also work for implicit initialization, but DMD complains since 2.072.0-b1 assert(ta.kind == TA.Kind.null_); ta = 12; @@ -338,8 +338,7 @@ unittest { // std.conv integration alias TA = TaggedAlgebraic!Test; - TA ta; - ta = TA(12, TA.Kind.count); + TA ta = TA(12, TA.Kind.count); assert(ta.kind == TA.Kind.count); assert(ta == 12); @@ -1074,12 +1073,12 @@ private template isNoVariant(T) { private void rawEmplace(T)(void[] dst, ref T src) { - T* tdst = () @trusted { return cast(T*)dst.ptr; } (); + T[] tdst = () @trusted { return cast(T[])dst[0 .. T.sizeof]; } (); static if (is(T == class)) { - *tdst = src; + tdst[0] = src; } else { import std.conv : emplace; - emplace(tdst); - *tdst = src; + emplace!T(&tdst[0]); + tdst[0] = src; } }