If I copy & paste the following code into the ROOT6 interpreter:
* ROOT v6.02/00-rc1 *
double x[10] = {0};
for(unsigned int i = 0; i < 10; i++)
{
x[i] = i*i*i;
}
I get the following errors:
root [0] double x[10] = {0};
root [1] for(unsigned int i = 0; i < 10; i++)
root [2] {
root (cont'ed, cancel with .@) [3] x[i] = i*i*i;
root (cont'ed, cancel with .@) [4] }
ROOT_prompt_3:1:2: error: array subscript is not an integer
x[i] = i*i*i;
^~
ROOT_prompt_3:1:8: error: use of undeclared identifier 'i'
x[i] = i*i*i;
^
ROOT_prompt_3:1:10: error: use of undeclared identifier 'i'
x[i] = i*i*i;
^
ROOT_prompt_3:1:12: error: use of undeclared identifier 'i'
x[i] = i*i*i;
^
It still happens with a few alterations like using signed int, or different bracket style. In ROOT5, I get no error but the array is unchanged:
* ROOT v5.34/18 *
root [0]
root [0] double x[10] = {0};
root [1] for(unsigned int i = 0; i < 10; i++)
root [2] {
end with '}', '@':abort > x[i] = i*i*i;
end with '}', '@':abort > }
(double)1.00000000000000000e+03
root [3] x[9]
(double)0.00000000000000000e+00
I’m pretty sure I’m not doing some newbie mistake, as the expected thing happens in ideone: http://ideone.com/ffFWDs.
So what’s going on?
Jean-François