This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: fold: &a[i1] + c * i2 -> &a[i1 + i2] messing up types
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 9 Feb 2005 15:56:23 +0100 (CET)
- Subject: Re: fold: &a[i1] + c * i2 -> &a[i1 + i2] messing up types
On Wed, 9 Feb 2005, Zdenek Dvorak wrote:
> Hello,
>
> > Consider (C++)
> >
> > int a[1024];
> >
> > int *foo(unsigned short i, long long int j)
> > {
> > return &a[i]+j;
> > }
> >
> > transformed to
> >
> > int* foo(short unsigned int, long long int) (i, j)
> > {
> > int * D.1567;
> > int D.1568;
> > unsigned int D.1569;
> > unsigned int D.1570;
> >
> > D.1568 = (int) i;
> > D.1569 = (unsigned int) j;
> > D.1570 = D.1568 + D.1569;
> > D.1567 = &a[D.1570];
> > return D.1567;
> > }
> >
> > is the cast of j to (unsigned int) working by pure luck - what about
> > j == -1?
>
> then j will be casted to unsigned int. That's perfectly ok.
Indeed. I missed that pointers are unsigned.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/