This is the mail archive of the gcc-patches@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]

[patch, fortran] Fix PR38709, ice-on-invalid-code


Attached patch fixes an ICE-on-invalid with zero-sized arrays in 
initialization expressions.


2009-04-04  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/38709
	* expr.c (find_array_section): Leave early on zero-sized arrays.

2009-04-04  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/38709
	* gfortran.dg/zero_sized_6.f90: New.


Regression tested on i686-pc-linux-gnu. Ok for trunk?

Cheers

	Daniel

Index: expr.c
===================================================================
--- expr.c	(revision 145538)
+++ expr.c	(working copy)
@@ -1210,7 +1210,12 @@ find_array_section (gfc_expr *expr, gfc_
 	    }
 
 	  gcc_assert (begin->rank == 1);
-	  gcc_assert (begin->shape);
+	  /* Zero-sized arrays have no shape, stop early.  */
+	  if (!begin->shape) 
+	    {
+	      mpz_init_set_ui (nelts, 0);
+	      break;
+	    }
 
 	  vecsub[d] = begin->value.constructor;
 	  mpz_set (ctr[d], vecsub[d]->expr->value.integer);
! { dg-do "compile" }
! PR38709 - ICE-on-invalid on zero-sized array in init-expr.

  INTEGER, PARAMETER :: a(1) = (/ 1 /)
  INTEGER, PARAMETER :: i = a(shape(1))   ! { dg-error "Incompatible ranks" }
END

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