From: Rico Tzschichholz Date: Sat, 2 Sep 2017 07:46:33 +0000 (+0200) Subject: codegen: Initialize temp-variable for fixed-size arrays to zero first X-Git-Tag: 0.38.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8d47c0c883b3c97ff5dce932d785f25b8464494;p=thirdparty%2Fvala.git codegen: Initialize temp-variable for fixed-size arrays to zero first https://bugzilla.gnome.org/show_bug.cgi?id=787152 --- diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala index 2b78bbc7d..ea0a85ded 100644 --- a/codegen/valaccodearraymodule.vala +++ b/codegen/valaccodearraymodule.vala @@ -44,6 +44,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule { // no heap allocation for fixed-length arrays var temp_var = get_temp_variable (array_type, true, expr); + temp_var.init = true; var name_cnode = get_variable_cexpression (temp_var.name); int i = 0; diff --git a/tests/Makefile.am b/tests/Makefile.am index 48c0cb0eb..b3e5f7cc8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -47,6 +47,7 @@ TESTS = \ basic-types/bug771626.test \ basic-types/bug772426.vala \ basic-types/bug777697.test \ + basic-types/bug787152.vala \ chainup/class-base.vala \ chainup/class-base-foo.vala \ chainup/class-object.vala \ diff --git a/tests/basic-types/bug787152.vala b/tests/basic-types/bug787152.vala new file mode 100644 index 000000000..a6ae36b85 --- /dev/null +++ b/tests/basic-types/bug787152.vala @@ -0,0 +1,8 @@ +void main () { + int test[6] = { 23, 4711, 42 }; + assert (test[4] == 0); + assert (test[5] == 0); + int test2[6] = test; + assert (test2[4] == 0); + assert (test2[5] == 0); +}