This is the mail archive of the gcc-patches@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]

Re: PATCH: BPs & cleanups for ARRAY_SIZE


Greg McGary <greg@mcgary.org> writes:
> Jeffrey A Law <law@cygnus.com> writes:
> 
> > I'm not really sure I understand the benefit in optabs.c and emit-rtl.c,
> 
> Those are the changes that avoid bounds violations.  With BPs, array
> accesses are constrained to occur within the bounds of each dimension
> of the array.  By treating a multi-dimensional array as flat, you
> break down its internal "walls".

But, isn't that allowed in C?

  int a[3][3][3];
  p = (int *) a;

'p' should get the same bounds as 'a':

  [ (char *)a, (char *)a + 27*sizeof(int) )

Then, there's no violation of bounds if 'p' is stepped 27 times,
instead of nested loops.

- Hari
-- 
Raja R Harinath ------------------------------ harinath@cs.umn.edu
"When all else fails, read the instructions."      -- Cahn's Axiom
"Our policy is, when in doubt, do the right thing."   -- Roy L Ash

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