public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Per Bothner <bothner@cygnus.com>
To: egcs@cygnus.com
Subject: Re: Fortran array indexing on 64-bit targets & snapshot 971023
Date: Sun, 26 Oct 1997 10:31:00 -0000	[thread overview]
Message-ID: <199710261830.KAA06346@cygnus.com> (raw)
In-Reply-To: <24420.877882302@hurl.cygnus.com>

While hacking on Chill, I got convinced that the way Gcc represents
ranges just does not work.

Gcc represents a range as [min_index, max_index].  What type should these
have?  It seems that min_index and max_index should have the same type as
the index type.  This matters for languages like Pascal, Chill, and Ada (?)
that have index types that can be enums.  The problem is that this does
not work for empty ranges.  In that case max_index==min_index-1, which
might well not be in the index type.  This is a problem even for C,
if the index type is unsigned:  While ANIS C does not have empty arrays,
Gcc C does.  The result is a max_index of (size_t)(-1).  Ooops.

On the other hand, using a signed size_t (internally), may cause some
problems with really large ranges.  E.g.:  [-2147483648 .. 2147483647].

Finally, converting a length to an upperbound requires a calcaulation.
If the length is non-constant, converting the upperbound back again
to a length may not constant fold back to the original length, leading
to bad code.

My conclusion is that we should use differt types for the upper bound
and the length of an array (or integer range in general).  The upper
bound should got be stored explicitly;  instead we should store the
length - as an unsigned.  That is we shold get rid of TYPE_MAX_VALUE,
and replace it by TYPE_LENGTH.

But that is too much work, so it will never happen.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner

	

  reply	other threads:[~1997-10-26 10:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-24  5:26 Toon Moene
1997-10-24  8:03 ` Jeffrey A Law
1997-10-24 11:21   ` Toon Moene
1997-10-26  5:26   ` Toon Moene
1997-10-26  8:09     ` Jeffrey A Law
1997-10-26 10:31       ` Per Bothner [this message]
1997-10-27 14:46       ` Jim Wilson

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=199710261830.KAA06346@cygnus.com \
    --to=bothner@cygnus.com \
    --cc=egcs@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).