Dear ROOT experts,
We are puzzled by the behavior we see when we moved from ROOT < 5.28 to ROOT > 5.28 (still the case in 5.33/01) concerning a branch created from something pointed to by an auto_ptr.
The basics are:
std::auto_ptr<test::TEST_STRUCT> data(new test::TEST_STRUCT); // Create tree and branch. TFile* f = new TFile("test.root", "recreate"); TTree* t = new TTree("test", "test"); // This segfaults in 5.26, works in 5.28. //t->Branch("test.", "test::TEST_STRUCT", data.get()); // This works in 5.26, gives random results in 5.28. t->Branch("test.", "test::TEST_STRUCT", &data);
I have attached a tarball with a small example. Instructions for use (after unpacking):
make clean && make install ./bin/test_write && root -b -q test_read.C
You will see that depending on the way the branch is created and on the ROOT version this will either produce the right results (testInt = 0 and testTimestamp = 1234567890), segfault or produce random numbers.
Are we doing something wrong with the ampersand trick? From the release notes we saw that in 5.28 there is official ROOT support for auto_ptr IO. It would be nice to understand what goes on in all four cases though.
Thanks in advance for your help.
Andrzej & Jeroen
test_auto_ptr_io.tar.gz (10.2 KB)