[vala/0.36: 52/212] 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/0.36: 52/212] codegen: Initialize temp-variable for fixed-size arrays to zero first
- Date: Sat, 14 Apr 2018 07:47:43 +0000 (UTC)
commit 427ef81a86c3857bc86276dd35c12084ee065ee9
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 16724e3..ab30d62 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,6 +45,7 @@ TESTS = \
basic-types/bug761736.vala \
basic-types/bug771626.test \
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]