This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/32140] [4.3 Regression] Miscompilation with -O1



------- Comment #17 from pinskia at gcc dot gnu dot org  2007-06-17 22:08 -------
Here is the fix which I am testing, basically instead of creating
(typeof(array[0] "*")&array we create &array[lb]:
Index: trans.c
===================================================================
--- trans.c     (revision 125777)
+++ trans.c     (working copy)
@@ -266,7 +266,14 @@ gfc_build_addr_expr (tree type, tree t)
       && TREE_CODE (base_type) == ARRAY_TYPE
       && TYPE_MAIN_VARIANT (TREE_TYPE (type))
         == TYPE_MAIN_VARIANT (TREE_TYPE (base_type)))
-    natural_type = type;
+    {
+      tree min_val = size_zero_node;
+      tree type_domain = TYPE_DOMAIN (base_type);
+      if (type_domain && TYPE_MIN_VALUE (type_domain))
+       min_val = TYPE_MIN_VALUE (type_domain);
+      t = build4 (ARRAY_REF, TREE_TYPE (type), t, min_val, NULL_TREE,
NULL_TREE);
+      natural_type = type;
+    }
   else
     natural_type = build_pointer_type (base_type);


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]