FORTRAN -[patch for PR 9263 ICE caused by invalid PARAMETER in implied DO loop]

bdavis bdavis9659@comcast.net
Sun Apr 6 03:15:00 GMT 2003


Here is the problem:

Symbolic integer constant declared via PARAMETER not explicitly declared
as INTEGER (and not implicitly of type INTEGER) causes ICE if used as
a limit in an implied DO loop.


Example: <from PR 9263>

      PARAMETER (P=10)
      INTEGER C(10)
      DATA (C(I),I=1,P) /10*10/
      END

Gives (with every version of g77 I have):

bdavis@rh sbox6apr]$ /usr/bin/g77 ice.f
f771: ../../gcc/f/data.c:602: ffedata_advance_: Assertion 
`(((end)->info).basictype) == FFEINFO_basictypeINTEGER' failed.
ice.f: In program `MAIN__':
ice.f:3: internal error: Aborted
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.

The patch which diagnoses this illegal code (F77 requires the terminal 
value of an implied do loop in a data statement to be an Integer 
Constant Expression (some exceptions to this in the standard, but not 
relevant to this discussion)):

Index: gcc/gcc/f/data.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/data.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 data.c
*** gcc/gcc/f/data.c    13 Feb 2002 07:39:56 -0000      1.8
--- gcc/gcc/f/data.c    6 Apr 2003 02:47:35 -0000
*************** tail_recurse:                   /* ::::::::::::::::::::
*** 598,603 ****
--- 598,612 ----
                == FFEINFO_kindtypeINTEGERDEFAULT);
        ffesymbol_set_value (ffedata_stack_->itervar, 
ffedata_eval_integer1_ (start));

+         if (ffeinfo_basictype (ffebld_info (end)) != 
FFEINFO_basictypeINTEGER)
+           {
+              ffebad_start (FFEBAD_DATA_EVAL);
+              ffest_ffebad_here_current_stmt (0);
+              ffebad_finish ();
+              ffedata_pop_ ();
+              ffedata_reported_error_ = TRUE;
+              return FALSE;
+           }
        assert (ffeinfo_basictype (ffebld_info (end))
                == FFEINFO_basictypeINTEGER);
        assert (ffeinfo_kindtype (ffebld_info (end))


No regressions caused by this patch on i386-gnu-linux.

The example given above is a test case to be added to the "non-compile" 
directory, since this code is not valid FORTRAN.

How the test case is processed after the patch:

[bdavis@rh sbox6apr]$ /usr/local/bin/g77 ice.f
ice.f: In program `MAIN__':
ice.f:4:
         DATA (C(I),I=1,P) /10*10/
         ^
Not an integer constant expression in implied do-loop in statement at (^)


--bud davis




More information about the Gcc-patches mailing list