]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix cast from non-array to array
authorJürg Billeter <j@bitron.ch>
Tue, 19 Oct 2010 17:35:54 +0000 (19:35 +0200)
committerJürg Billeter <j@bitron.ch>
Tue, 19 Oct 2010 17:35:54 +0000 (19:35 +0200)
Array length will be set to -1 as there is no length information
available in this case.

codegen/valaccodebasemodule.vala

index c970eaf975b91a665b1ac39245fa79aa9401c06d..a1bc6998c77dee5555c312f66b7c9aeb05772a08 100644 (file)
@@ -4569,6 +4569,12 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                                for (int dim = 1; dim <= array_type.rank; dim++) {
                                        append_array_size (expr, get_array_length_cexpression (expr.inner, dim));
                                }
+                       } else if (array_type != null) {
+                               // cast from non-array to array, set invalid length
+                               // required by string.data, e.g.
+                               for (int dim = 1; dim <= array_type.rank; dim++) {
+                                       append_array_size (expr, new CCodeConstant ("-1"));
+                               }
                        }
 
                        var innercexpr = get_cvalue (expr.inner);