diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9939009e608626c63a247414b9a0450dac0c01b0..96c4fcad84350b688a291f6a9d3fbfbd00bc996f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2002-03-21  Eric Botcazou <ebotcazou@multimania.com>
+
+	PR c/5597
+	* c-typeck.c (process_init_element): Flag non-static
+	initialization of a flexible array member as illegal.
+
 2002-03-22  Alan Modra  <amodra@bigpond.net.au>
 
 	* config/rs6000/t-linux64: New.
@@ -10,19 +16,19 @@
 
 2002-03-21  Aldy Hernandez  <aldyh@redhat.com>
 
-        * langhooks.c (lhd_tree_inlining_cannot_inline_tree_fn): Check
-        flag_really_no_inline instead of optimize == 0.
+	* langhooks.c (lhd_tree_inlining_cannot_inline_tree_fn): Check
+	flag_really_no_inline instead of optimize == 0.
 
-        * c-objc-common.c (c_cannot_inline_tree_fn): Same.
+	* c-objc-common.c (c_cannot_inline_tree_fn): Same.
 
-        * cp/tree.c (cp_cannot_inline_tree_fn): Same.
+	* cp/tree.c (cp_cannot_inline_tree_fn): Same.
 
-        * flags.h (flag_really_no_inline): New.
+	* flags.h (flag_really_no_inline): New.
 
-        * c-common.c (c_common_post_options): Initialzie
-        flag_really_no_inline.
+	* c-common.c (c_common_post_options): Initialzie
+	flag_really_no_inline.
 
-        * toplev.c (flag_really_no_inline): New.
+	* toplev.c (flag_really_no_inline): New.
 
 2002-03-21  Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 1772557449c4ffb400faaa3a1bb27ab25b82ebfa..297b0f9e188d4952590fcf823b00219b7b4dc18f 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -6537,6 +6537,16 @@ process_init_element (value)
 	    fieldtype = TYPE_MAIN_VARIANT (fieldtype);
 	  fieldcode = TREE_CODE (fieldtype);
 
+	  /* Error for non-static initialization of a flexible array member.  */
+	  if (fieldcode == ARRAY_TYPE
+	      && !require_constant_value
+	      && TYPE_SIZE (fieldtype) == NULL_TREE
+	      && TREE_CHAIN (constructor_fields) == NULL_TREE)
+	    {
+	      error_init ("non-static initialization of a flexible array member");
+	      break;
+	    }
+
 	  /* Accept a string constant to initialize a subarray.  */
 	  if (value != 0
 	      && fieldcode == ARRAY_TYPE
diff --git a/gcc/testsuite/gcc.dg/array-6.c b/gcc/testsuite/gcc.dg/array-6.c
new file mode 100644
index 0000000000000000000000000000000000000000..6ef64625b964ec73bed3203bd83fde3dfb723a6b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/array-6.c
@@ -0,0 +1,18 @@
+/* PR c/5597 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* Verify that GCC forbids non-static initialization of
+   flexible array members. */
+
+struct str { int len; char s[]; };
+
+struct str a = { 2, "a" };
+
+void foo()
+{
+  static struct str b = { 2, "b" };
+  struct str c = { 2, "c" }; /* { dg-error "(non-static)|(near initialization)" } */
+  struct str d = (struct str) { 2, "d" }; /* { dg-error "(non-static)|(near initialization)" } */
+  struct str e = (struct str) { d.len, "e" }; /* { dg-error "(non-static)|(initialization)" } */
+}