[pkg-d-commits] [ldc] 132/149: Don't crash when trying to repaint static arrays (#2034)

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:37:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.2.0
in repository ldc.

commit 94f04216d04faa6a97d78890a808537dd3b38662
Author: kinke <kinke at users.noreply.github.com>
Date:   Sat Mar 18 14:21:25 2017 +0100

    Don't crash when trying to repaint static arrays (#2034)
    
    Fixes issue #2033.
---
 gen/llvmhelpers.cpp       |  8 ++++++--
 tests/compilable/gh2033.d | 11 +++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp
index 9b85d03..d866857 100644
--- a/gen/llvmhelpers.cpp
+++ b/gen/llvmhelpers.cpp
@@ -727,8 +727,12 @@ DValue *DtoPaintType(Loc &loc, DValue *val, Type *to) {
     LLValue *ptr = DtoBitCast(DtoRVal(val), DtoType(b));
     return new DImValue(to, ptr);
   }
-  // assert(!val->isLVal()); TODO: what is it needed for?
-  assert(DtoType(to) == DtoType(to));
+  if (from->ty == Tsarray) {
+    assert(to->toBasetype()->ty == Tsarray);
+    LLValue *ptr = DtoBitCast(DtoLVal(val), DtoPtrToType(to));
+    return new DLValue(to, ptr);
+  }
+  assert(DtoType(from) == DtoType(to));
   return new DImValue(to, DtoRVal(val));
 }
 
diff --git a/tests/compilable/gh2033.d b/tests/compilable/gh2033.d
new file mode 100644
index 0000000..8c736b0
--- /dev/null
+++ b/tests/compilable/gh2033.d
@@ -0,0 +1,11 @@
+// RUN: %ldc -c %s
+
+void foo(const(uint)[4] arg)
+{
+    // The front-end coerces the explicit and following implicit cast
+    // (implicit: int[4] -> const(int[4])) into a single CastExp with
+    // differing types CastExp::to and CastExp::type.
+    // Make sure the repainting code performing the implicit cast
+    // handles static arrays.
+    const copy = cast(int[4]) arg;
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list