public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about pointer arithmetics in GIMPLE
@ 2005-08-21 18:32 Falk Hueffner
  2005-08-22 22:50 ` Jeffrey A Law
  0 siblings, 1 reply; 3+ messages in thread
From: Falk Hueffner @ 2005-08-21 18:32 UTC (permalink / raw)
  To: gcc; +Cc: law

Hi,

I'm trying to implement a tree pass that warns about bad array
accesses as suggested for PR 8268 by Jeff Law. However, I have trouble
with the following:

char digit_vector[5];
const char *ggc_alloc_string(int length) {
    return digit_vector + ((length - 17) * 2);
}

this translates to:

ggc_alloc_string (length)
{
  const char * D.1292;
  int D.1293;
  long unsigned int D.1294;
  char * D.1295;
  char * D.1296;

  D.1293 = length * 2;
  D.1294 = (long unsigned int) D.1293;
  D.1295 = (char *) D.1294;
  D.1296 = &digit_vector + -34B;     <-----------
  D.1292 = D.1295 + D.1296;
  return D.1292;
}

that is, a pointer is formed that wouldn't be legal to form from C,
and we end up with

  return (char *) (long unsigned int) (length * 2) + &digit_vector[-000000022];

producing a warning. Is that correct GIMPLE? If so, I fear it simply
isn't possible to do this kind of warnings after gimplification, and,
if at all possible, would have to be done in the front-end after all.

-- 
	Falk

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-08-22 22:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-21 18:32 Question about pointer arithmetics in GIMPLE Falk Hueffner
2005-08-22 22:50 ` Jeffrey A Law
2005-08-22 23:35   ` Daniel Berlin

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).