Hello Dariusz,
Thank you for your comment. This is one of frequently asked
questions. I do not like this array boundary check either, but it
comes from ANSI C standard. It says C language processor must
allow access to an array element one beyond the boundary. In your
example, ar[20] must be allowed. There are existing C/C++ code
depending on this behavior. For example, STL interator relies on
it, somehow. If vector<T>::iterator is T*, then
vector<T> a(20); // vector of size 20
vector<T>::iterator first = a.begin(); // &a[0]
vector<T>::iterator last = a.end(); // &a[20] one beyond
boundary
Masaharu Goto
----- Original Message -----
From: "Rene Brun" <Rene.Brun@cern.ch>
To: "Dariusz Miskowiec" <D.Miskowiec@gsi.de>
Cc: <cint@pcroot.cern.ch>
Sent: Monday, September 16, 2002 10:44 PM
Subject: [CINT] Re: [ROOT] array boundary checking
> Hi Dariusz,
>
> I forward your mail to Masa and CINT newsgroup
>
> Rene Brun
>
> On Mon, 16 Sep 2002, Dariusz Miskowiec wrote:
>
> > Hello ROOT team
> >
> > I have the impression that ROOT (3.03/08 on linux) is too
> > tolerant:
> >
> > root [0] int ar[20]
> > root [1] ar[0]
> > (int)0
> > root [2] ar[19]
> > (int)0
> > root [3] ar[20]
> > (int)0
> > root [4] ar[21]
> > Error: Array index out of range ar[21] -> [21] valid upto ar[19]
FILE:/tmp/filelcNbJE_cint LINE:1
> > *** Interpreter error recovered ***
> >
> > Best regards
> > Dariusz Miskowiec
> >
> > --
> > +-----------------------------------------------------------------+
> > + Dariusz Miskowiec E-mail: D.Miskowiec@gsi.de +
> > + GSI, Planckstr. 1 Phone: 0049-6159-712-133 +
> > + D-64291 Darmstadt Fax: 0049-6159-712-989 +
> > +-----------------------------------------------------------------+
> >
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET