Fortran Programming Guide

Subscript Bounds (-C)

The -C option adds checks for out-of-bounds array subscripts.

If you compile with -C, the compiler adds checks at runtime for out-of-bounds references on each array subscript. This action helps catch some situations that cause segmentation faults.

Example: Index out of range:


demo% cat indrange.f
      REAL a(10,10)
      k = 11
      a(k,2) = 1.0
      END
demo% f77 -C -silent indrange.f
demo% a.out
 Subscript out of range on file indrange.f, line 3, procedure MAIN. 
 Subscript number 1 has value 11 in array a. 
 Abort (core dumped) 
demo%