Possible bug in vector initialization

Dear Root/CInt users,

I did this test in ROOT:

root [0] Float_t axis[] = {1., 2., 3., 4.}
root [1] axis[1]
(Float_t)2.00000000000000000e+00
root [2] axis[4]
(Float_t)0.00000000000000000e+00

But element axis[4] does not exist!
When I try to acess the element 5 I get this message:

root [6] a[5]
Error: Array index out of range a[5] -> [5] valid upto a[3] FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***

It doesn’t seen a big trouble, but if I pass this vector as an axis for a histogram I get this error message:
Error in TAxis::TAxis::Set: bins must be in increasing order

I’m using ROOT 3.05/07
gcc 3.2.2
Linux kernel : 2.4.21

Obs: In another machine with ROOT 3.05/06 i didn’t get last error message!

Thanks, Luís

This is the expected behaviour from CINT. CINT always keep a margin of one for internal technical reasons.

Could you tell how you use your vector when creating your TH1F?
Please read carefully the doc when creating an histogram with variable bin size. You must fill N+1 elements in your vector if you create
an histogram with N bins.

Rene

Hello Rene,

After a reboot of my machine my script worked fine… I guess it is hardware instability.

Thanks for your explanations, and I’m sorry by false bug :blush:

Cheers, Luís