This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/30514] zero-sized array wrongly rejected: integer :: i(1:-1)
- From: "pault at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jan 2007 21:05:30 -0000
- Subject: [Bug fortran/30514] zero-sized array wrongly rejected: integer :: i(1:-1)
- References: <bug-30514-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from pault at gcc dot gnu dot org 2007-01-22 21:05 -------
This fixes the PR but I have not yet determined if it is standard conforming
behaviour:
Index: gcc/fortran/array.c
===================================================================
*** gcc/fortran/array.c (revision 120859)
--- gcc/fortran/array.c (working copy)
*************** match_array_element_spec (gfc_array_spec
*** 319,324 ****
--- 319,333 ----
if (m == MATCH_NO)
return AS_ASSUMED_SHAPE;
+ /* If the size is negative in this dimension, set it to zero. */
+ if ((*lower)->expr_type == EXPR_CONSTANT
+ && (*upper)->expr_type == EXPR_CONSTANT
+ && mpz_cmp ((*upper)->value.integer, (*lower)->value.integer) < 0)
+ {
+ gfc_free_expr (*upper);
+ *upper = gfc_copy_expr (*lower);
+ mpz_sub_ui ((*upper)->value.integer, (*upper)->value.integer, 1);
+ }
return AS_EXPLICIT;
}
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-01-20 17:19:49 |2007-01-22 21:05:29
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30514