[vala] codegen: Initialize temp-variable for fixed-size arrays to zero first
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Initialize temp-variable for fixed-size arrays to zero first
- Date: Sat, 2 Sep 2017 15:42:07 +0000 (UTC)
commit e8d47c0c883b3c97ff5dce932d785f25b8464494
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Sep 2 09:46:33 2017 +0200
codegen: Initialize temp-variable for fixed-size arrays to zero first
https://bugzilla.gnome.org/show_bug.cgi?id=787152
codegen/valaccodearraymodule.vala | 1 +
tests/Makefile.am | 1 +
tests/basic-types/bug787152.vala | 8 ++++++++
3 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 2b78bbc..ea0a85d 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 48c0cb0..b3e5f7c 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 0000000..a6ae36b
--- /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);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]