public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeffrey A Law <law@cygnus.com>
To: Toon Moene <toon@moene.indiv.nluug.nl>
Cc: egcs@cygnus.com
Subject: Re: Fortran array indexing on 64-bit targets & snapshot 971023
Date: Sun, 26 Oct 1997 08:09:00 -0000	[thread overview]
Message-ID: <24420.877882302@hurl.cygnus.com> (raw)
In-Reply-To: <9710261322.AA08510@moene.indiv.nluug.nl>

  In message < 9710261322.AA08510@moene.indiv.nluug.nl >you write:
  > > I believe Jim is referring to this:
  > 
  > [ In expand_expr, case ARRAY_REF: ]
  > 
  > [ ... ]
  > 
  >         /* Optimize the special-case of a zero lower bound.
  > 
  >            We convert the low_bound to sizetype to avoid some problems
  >            with constant folding.  (E.g. suppose the lower bound is 1,
  >            and its mode is QI.  Without the conversion,  (ARRAY
  >            +(INDEX-(unsigned char)1)) becomes ((ARRAY+(-(unsigned  
  > char)1))
  >            +INDEX), which becomes (ARRAY+255+INDEX).  Oops!)
  > 
  >            But sizetype isn't quite right either (especially if
  >            the lowbound is negative).  FIXME */
  > 
  > [ ... ]
  > 
  > The problem is that you cannot be sure that sizetype is signed (see  
  > functions `make_signed_type' and `make_unsigned_type' in  
  > stor-layout.c).
  > 
  > Why it's done this way is beyond me ...
I'd been thinking about this offline and was starting to wonder if
the FIXME really meant that the problem was sizetype was the wrong
type for the conversion and could cause problems.

And the more I think about it, the more I believe that's the real
issue with that code.

For historical reasons, the call into make_[un]signed_type has always
been with the argument "INT_TYPE_SIZE".  And if no value for sizetype
existed, then it was set to the type created by that first call.

[ An aside, I think all the front ends actually assign a real sizetype
  independent of this braindamage in make_[un]signed_type. ]

So, consider what happens with sizeof (int) < sizeof (pointer) and
the lowbound is negative.  We run into the exact same problem
mentioned in the comment.

So it would seem like the comment really means that "sizetype" may
not be the correct type for the conversion.  But that's the closest
global thing we've currently got to the correct type -- though I wonder
why indextype wasn't used.  Oh I see, we convert index to sizetype
just after we fold out the bias.

It's worth noting that having sizetype be smaller than the size
of a pointer is a bad thing -- a few obscure ports still do this
(z8 perhaps?), but I'm not too worried about them since they've
already got some serious problems.

I don't really see any reason to not install this patch.

Comments?

jeff

  reply	other threads:[~1997-10-26  8:09 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 [this message]
1997-10-26 10:31       ` Per Bothner
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=24420.877882302@hurl.cygnus.com \
    --to=law@cygnus.com \
    --cc=egcs@cygnus.com \
    --cc=toon@moene.indiv.nluug.nl \
    /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).