------- Comment #5 from burnus at gcc dot gnu dot org  2009-01-24 19:41 -------
(In reply to comment #4)
> After adding the the missing checks to gfc_check_cshift() and
> gfc_check_eoshift() respectively, I get a couple of errors for
> gfortran.dg/zero_sized_1.f90 [...]

Thanks! The errors look OK.

> Are runtime checks required to check the shape of the other arguments if ARRAY
> is zero-sized?

Good question. For completeness, one can add the check, which is also included
in NAG f95 (which does not have a compile-time check):

  real, dimension(4,0) :: a,c
  integer :: b(1)
  c = eoshift (a, shift=b(2:1)) ! OK - shape = 0
  c = eoshift (a, shift=b(1))   ! OK - scalar
  c = eoshift (a, shift=b(1:1)) ! Wrong: shape = 1 vs. 0
  end

Shape mismatch (dimension 1) between ARRAY and SHIFT in CSHIFT
Program terminated by fatal error
In $main$, line 5 of shapetest.f90

In any case, the check should only be enabled with -fbounds-check and enclosed
with if(unlikely(option...)). If the normal program flow is too much
interrupted, one can also think about not adding the run-time check for
zero-sized arrays.


-- 


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

Reply via email to