]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: TypeInfo error when using slice copy on Structs (PR100964)
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 9 Jun 2021 17:39:28 +0000 (19:39 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 9 Jun 2021 17:52:12 +0000 (19:52 +0200)
Known limitation: does not work for struct with postblit or dtor.

gcc/d/ChangeLog:

PR d/100964
* dmd/expression.c (Expression::checkPostblit): Don't generate
TypeInfo when RTTI is disabled.

gcc/testsuite/ChangeLog:

PR d/100964
* gdc.test/compilable/betterCarray.d: Add test cases.

(cherry picked from commit 036e14ca44eaddf329a79d56d556862118b1f220)

gcc/d/dmd/expression.c
gcc/testsuite/gdc.test/compilable/betterCarray.d

index 2592b38d961b74354fc292bb2853027bb75fae3c..88f13e9669bcfe3c0f23076a07d9afded8c1f695 100644 (file)
@@ -1044,8 +1044,11 @@ bool Expression::checkPostblit(Scope *sc, Type *t)
     t = t->baseElemOf();
     if (t->ty == Tstruct)
     {
-        // Bugzilla 11395: Require TypeInfo generation for array concatenation
-        semanticTypeInfo(sc, t);
+        if (global.params.useTypeInfo)
+        {
+            // Bugzilla 11395: Require TypeInfo generation for array concatenation
+            semanticTypeInfo(sc, t);
+        }
 
         StructDeclaration *sd = ((TypeStruct *)t)->sym;
         if (sd->postblit)
index 74c80be3b95bd546497a851758c564a2fd247e45..3f48b042bde5515a66803ab90168e7d078c6f2c5 100644 (file)
@@ -15,3 +15,13 @@ int foo(int[] a, int i)
 {
     return a[i];
 }
+
+/**********************************************/
+// https://issues.dlang.org/show_bug.cgi?id=19234
+void issue19234()
+{
+    static struct A {}
+    A[10] a;
+    A[10] b;
+    b[] = a[];
+}