Re: array bounds checking

"Sudesh Chandna, Noida" <sudeshc@noida.hcltech.com>
29 Nov 2005 16:09:05 -0500

          From comp.compilers

Related articles
array bounds checking drizzle76@gmail.com (dz) (2005-11-26)
Re: array bounds checking nmm1@cus.cam.ac.uk (2005-11-27)
Re: array bounds checking sudeshc@noida.hcltech.com (Sudesh Chandna, Noida) (2005-11-29)
Re: array bounds checking gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-12-03)
Re: array bounds checking neal.wang@gmail.com (2005-12-08)
Re: Array bounds checking pardo@june.cs.washington.edu (1990-06-15)
| List of all articles for this month |

From: "Sudesh Chandna, Noida" <sudeshc@noida.hcltech.com>
Newsgroups: comp.compilers
Date: 29 Nov 2005 16:09:05 -0500
Organization: Compilers Central
References: 05-11-121
Keywords: debug
Posted-Date: 29 Nov 2005 16:09:05 EST

Hi,


> I am wondering if anybody knew how array bounds checks worked when
>they are references through multiple indirections of pointers. Eg: p =
>A ; q= &p; ***q+100=0; So q is referencing A. And hence I would like a
>check inserted there.
>                   Do array bounds checking handle these cases, because
>this also would need pointer analysis.


This can be easily done by having a data structure commonly known as
"descriptor" for pointer which can hold lower bound, upper bound, stride
corresponding to all dimensions of the array. Also descriptor should have rank
( dimension ) and address of the array. Now for languages such as FORTRAN
where its possible to say


Ptr => ary(1:10:2)


Descriptor values lower bound would be 1
Upper bound would be 5
Stride would be say 8 (2*size of element)
Rank would be 1
And addr will hold starting address.


This information can be used at runtime to do bounds checking.


Thanks & Best Regards,
Sudesh Chandna
Senior Member Technical Staff


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.