------- Comment #3 from pinskia at gcc dot gnu dot org  2007-04-10 02:31 -------
This is the fix which I am going to fully test:
Index: c-decl.c
===================================================================
--- c-decl.c    (revision 123681)
+++ c-decl.c    (working copy)
@@ -3383,7 +3383,7 @@ c_maybe_initialize_eh (void)
 void
 finish_decl (tree decl, tree init, tree asmspec_tree)
 {
-  tree type = TREE_TYPE (decl);
+  tree type;
   int was_incomplete = (DECL_SIZE (decl) == 0);
   const char *asmspec = 0;

@@ -3410,6 +3410,8 @@ finish_decl (tree decl, tree init, tree
                            || TREE_CODE (decl) == FIELD_DECL))
     objc_check_decl (decl);

+  type = TREE_TYPE (decl);
+
   /* Deduce size of array from initialization, if not already known.  */
   if (TREE_CODE (type) == ARRAY_TYPE
       && TYPE_DOMAIN (type) == 0


------------------
Basically store_init_value changes the type of the decl but we never update the
variable type in finish_decl, so we get the wrong bounds as we now call
complete_array_type unnessararly and we get the wrong bounds as the CONSTRUCTOR
only has 3 elements but the type is defined as having 4 elements.  This was
introduced by PR 27184 because we now create a new type instead of just
updating the ARRAY_REF type.  (I still say there are other bugs dealing with
aliasing sets still set incorrectly but that is a different story and maybe
will file a bug about that later).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |27184
      Known to fail|                            |4.1.2 4.2.0 4.3.0
      Known to work|                            |4.1.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31520

Reply via email to