TClass of an abstract subclass incorrect?

Hi,
Using the attached code (and file) I am able to crash in a way I was not expecting. To summarize the source code, I load a TH1F from a file, then I get the TClass pointer for TH1F, then I get the list of bases, and then I look at the TH1 class from there, and when I get its list of bases I get back “CDCDCDCD” (on Windows) which is the value for an uninitalized word of memory. Is this behaving correctly? If so, how can I know before hand that the list of bases is going to be invalid like this? If this is expected behavior, is there anyway I can force it to load up whatever it needs so I get a valid class chain back?

I run this code with the command “root -l -b -q testload.cpp+”

And here is the code (also attached along with the file):

[code]#include

#include “TFile.h”
#include “TClass.h”
#include “TList.h”

using std::cout;
using std::endl;

void testload()
{
TFile *f = new TFile(“plots.root”, “READ”);
if (!f->IsOpen()) {
cout << “Error opening file” << endl;
return;
}

TObject *o = f->Get("anint_2");
if (o == 0) {
	cout << "Unable to load the object" << endl;
	return;
}

TClass *c = o->IsA();
if (c == 0) {
	cout << "Unable to get the class of the object" << endl;
	return;
}

cout << "Class is " << c->GetName() << endl; // Should be TH1F

TList *bases = c->GetListOfBases();
cout << "Bases pointer is " << bases << endl; // Should be valid pointer
cout << "  Bases length is " << bases->GetEntries() << endl; // Should be 2

c = static_cast<TClass*>(bases->At(0));
cout << "Subclass is " << c->GetName() << endl;
if (!c->IsLoaded()) {
	cout << "Expecting class to be loaded" << endl;
	return;
}

bases = c->GetListOfBases();
cout << "Bases pointer is " << bases << endl; // Should be valid pointer
cout << "  Bases length is " << bases->GetEntries() << endl; // Should be 2

f->Close();	

}
[/code]

Thanks in advaice!
plots.root (3.49 KB)
testload.cpp (1.12 KB)

Hi Gordon,

The object held in the list of class are not TClass but are TBaseClass. For example the call ls() on the first bases gives:OBJ: TList TList Doubly linked list : 0 OBJ: TBaseClass TH1 1-Dim histogram base class : 0 at: 0xd958e0 OBJ: TBaseClass TArrayF Array of floats : 0 at: 0xd95950.

Cheers,
Philippe.