This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFH] Folding of &a[-1]


> Richard Guenther wrote:
> While trying to implement folding of &a +- cst to &a[c] I came
> along the C frontend, which for
> 
>   int a[4];
>   int *p = &a[-1];
>
> produces
>
>   p = &a + (int *)-4;

Would guess it should be:

   p = &a - (int *)4;

or even:

   p = &a + - (int *)4;

Either yielding:

   &a[-4U/4U] from &a[-1]

Which would seem consistent.

(maybe in general negative unsigned values should be represented as a
 unary minus expression with an unsigned argument: (MINUS (CONST unsigned))

-paul-



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]