Problem with variable length array of custom class in a TTre


I have a problem accessing members of a variable length array of custom class objects with the TTree::Scan method.

I have attached a macro which reproduces the problem. There are two simple classes, the first ‘subDataClass’ contains a single parameter (int param). The second ‘mainDataClass’ contains a variable length array of subDataClass created as follows:

int nVar;
subDataClass* data;//[nVar]

I have a small function called go() which creates the class and fills dummy values into a TTree. Now, if I use the following:


then all the values are zero, instead of the dummy value.

any help appreciated

System OS X 10.6.6, Root SVN revision 37585, gcc 4.2.1

Sorry - forgot the attachment!
example.C (1.45 KB)


I can indeed reproduce the problem which is not easy to fix.
As a work-around, please replace your C-style array of object by a std::vector of object.


Hi - this workaround works