aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2003-03-05 09:37:57 +0100
committerEric Botcazou <ebotcazou@gcc.gnu.org>2003-03-05 08:37:57 +0000
commitbe2fa2118342b5a2b489de82cc73da4dd75b7771 (patch)
tree0b6881bad170240cc4a52a58d5d512ca08d66c77
parent8234c6c11a17ea58b80719e228bf6904351f34f6 (diff)
downloadgcc-be2fa2118342b5a2b489de82cc73da4dd75b7771.zip
gcc-be2fa2118342b5a2b489de82cc73da4dd75b7771.tar.gz
gcc-be2fa2118342b5a2b489de82cc73da4dd75b7771.tar.bz2
re PR c/9799 (mismatching structure initializer with nested flexible array member, segfaults)
PR c/9799 * c-typeck.c (push_init_level): Add sanity check. From-SVN: r63831
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c1
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20030305-1.c18
4 files changed, 28 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4d30aba..c2f7841 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2003-03-05 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR c/9799
+ * c-typeck.c (push_init_level): Add sanity check.
+
Wed Mar 5 02:04:04 CET 2003 Jan Hubicka <jh@suse.cz>
* toplev.c (rest_of_compilation): Deffer RTL compilation only when
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 8302a96..52105ac 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -5273,6 +5273,7 @@ push_init_level (implicit)
&& constructor_fields == 0)
process_init_element (pop_init_level (1));
else if (TREE_CODE (constructor_type) == ARRAY_TYPE
+ && constructor_max_index
&& tree_int_cst_lt (constructor_max_index, constructor_index))
process_init_element (pop_init_level (1));
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b67b566..0060172 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2003-03-05 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * gcc.c-torture/compile/20030305-1.c
+
Wed Mar 5 02:05:19 CET 2003 Jan Hubicka <jh@suse.cz>
* gcc.dg/i386-local.c: New.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20030305-1.c b/gcc/testsuite/gcc.c-torture/compile/20030305-1.c
new file mode 100644
index 0000000..2f60819
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20030305-1.c
@@ -0,0 +1,18 @@
+/* PR c/9799 */
+/* Verify that GCC doesn't crash on excess elements
+ in initializer for a flexible array member. */
+
+typedef struct {
+ int aaa;
+} s1_t;
+
+typedef struct {
+ int bbb;
+ s1_t s1_array[];
+} s2_t;
+
+static s2_t s2_array[]= {
+ { 1, 4 },
+ { 2, 5 },
+ { 3, 6 }
+};