On Fri, Jan 13, 2012 at 16:07, Tobias Burnus <bur...@net-b.de> wrote:
> Dear all,
>
> the front end uses for array indices (gfc_index_integer_kind /
> gfc_array_index_type) which is a signed integer of size POINTER_SIZE.
>
> The libgfortran library used to use
>   typedef ssize_t index_type;
> which fails if sizeof(void*) is not sizeof(ssize_t); the latter is the case
> on LP64 systems (see PR).

As a minor nitpick, not necessarily: E.g. x86_64-linux-gnu and most
64-bit Unix targets are also LP64 (as in, long and pointer are 64
bits), but older releases work there as ssize_t is also 64 bits. The
target in the PR is (was?) thus a bit "special", in that while it's
LP64, ssize_t is smaller than 64 bits.

> For 4.7 this was changed (in April 2011) to:
>    typedef ptrdiff_t index_type;
> which makes more sense - and should be sufficient for LP64 systems.
>
> However, mixing an POINTER_SIZE type with ptrdiff_t only works if
> sizeof(ptrdiff_t) == POINTER_SIZE; in principle, the maximally allowed size
> of a variable can be smaller (e.g. page size) than the maximally allowed
> pointer size. (sizeof() returns a result of type size_t). I do not know
> whether such systems exist in practice and whether such a system is
> supported by GCC.
>
> The attached patch makes let's the FE emit code of the same data type as
> used in libgfortran - ptrdiff_t for the array indices.
>
> Build and regtested on x86-64-linux.
> OK for the trunk?

Ok, thanks.

-- 
Janne Blomqvist

Reply via email to