This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question about pointer arithmetics in GIMPLE
- From: Falk Hueffner <falk at debian dot org>
- To: gcc at gcc dot gnu dot org
- Cc: law at redhat dot com
- Date: Sun, 21 Aug 2005 20:32:44 +0200
- Subject: Question about pointer arithmetics in GIMPLE
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