public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Craig Burley <burley@gnu.org>
To: bothner@cygnus.com
Cc: egcs@cygnus.com, rms@cygnus.com, kenner@cygnus.com
Subject: Re: array bounds check option
Date: Wed, 21 Jan 1998 09:54:00 -0000	[thread overview]
Message-ID: <199801211714.MAA15680@melange.gnu.org> (raw)
In-Reply-To: <199801192026.MAA11446@cygnus.com>

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)

  reply	other threads:[~1998-01-21  9:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-20  4:00 Per Bothner
1998-01-21  9:54 ` Craig Burley [this message]
1998-01-22  1:45   ` Per Bothner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199801211714.MAA15680@melange.gnu.org \
    --to=burley@gnu.org \
    --cc=bothner@cygnus.com \
    --cc=egcs@cygnus.com \
    --cc=kenner@cygnus.com \
    --cc=rms@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).