This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fortran array indexing on 64-bit targets & snapshot 971023
- To: egcs at cygnus dot com
- Subject: Re: Fortran array indexing on 64-bit targets & snapshot 971023
- From: Per Bothner <bothner at cygnus dot com>
- Date: Sun, 26 Oct 1997 10:32:03 -0800
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