Indexing arrays with Long64_t

Hi,

I’ve noticed what is (to me) unexpected behavior when looping over an array and denoting the array index with Long64_t. The address of elements after the first one appears to increment only by one byte rather than by the size of an array element as I would expect. This only occurs in interpreted code.

I show some example code below for more information. Is this an expected feature or a bug?

Thanks,
Greg

// index.C
#include <iostream>

Double_t* Array()
{
	static Double_t arr[5] = {0,1,2,3,4};
	return arr;
}

void index()
{
	std::cout << "Loop: \n";
	for(Long64_t i=0; i< 5; ++i)
		std::cout << "index " << i << ", val " << Array()[i] << ", addr " << Array() + i << std::endl;
}

/*
	output of '.x index.C'

index 0, val 0, addr 0x7fd4c25972a0
index 1, val 0, addr 0x7fd4c25972a1
index 2, val 0, addr 0x7fd4c25972a2
index 3, val 0, addr 0x7fd4c25972a3
index 4, val 0, addr 0x7fd4c25972a4
*/

If I run with ‘.x index.C+’, I get the expected output:

index 0, val 0, addr 0x109dba110
index 1, val 1, addr 0x109dba118
index 2, val 2, addr 0x109dba120
index 3, val 3, addr 0x109dba128
index 4, val 4, addr 0x109dba130

Likewise, it looks okay if I use Int_t rather than Long64_t for the loop variable (whether interpreted or compiled). If the array to be accessed is a local one, rather than a pointer returned by a function, I get the correct dereferencing but still the wrong addresses:

void indexlocal()
{
	Double_t arr[5] = {0,1,2,3,4};
	for(Long64_t i=0; i< 5; ++i)
		std::cout << "index " << i << ", val " << arr[i] << ", addr " << arr + i << std::endl;
}

/* output :
index 0, val 0, addr 0x7fda723ac930
index 1, val 1, addr 0x7fda723ac931
index 2, val 2, addr 0x7fda723ac932
index 3, val 3, addr 0x7fda723ac933
index 4, val 4, addr 0x7fda723ac934
*/