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

Re: array bounds check option


I'd suggest -farray-bounds-check, because "bounds" might be too
general ("range" certainly is).

E.g. consider whether someone might want an option to check the
range of values assigned to "enum"s, or types declared with
explicit ranges (a la Pascal).

Another idea is -fsubscript-bounds-check, or maybe if "subscript"
always pertains to arrays, -fsubscript-check.

However, it is important to determine just what is being checked,
and name the option accordingly.

In Fortran, given

  REAL A(5,5)

the reference

  A(6,2)

does not violate some Fortran compilers' *array* bounds checking,
but does violate *subscript* bounds.  (Using the canonical
computation, the reference is equivalent to A(1,3), I believe,
but the canonical computation is *not* standard Fortran, just
as adding 1 to 2147483647 producing -2147483648 is canonical
but not standard C.)

So I'd say -fsubscript-bounds-check is appropriate only if
you're putting a check on each ARRAY_REF node (or whatever
its called), while -farray-bounds-check is appropriate only if
you're checking the computed offset into the array against
the overall bounds of the array.

Of course, if you do the subscript checking (on ARRAY_REF),
and a front end collapses subscript references to computations
using lower-level constructs in the back end, that's a problem.
(g77 has an undocumented internal macro that happens to make
such a change; it was found useful by egcs people wishing to
experiment with improving g77 performance on Alphas and, I
believe, is no longer helpful due to the optimizations they
came up with.)

        tq vm, (burley)


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