Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tree/treeplayer/src/TTreeReaderArray.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ bool ROOT::Internal::TTreeReaderArrayBase::GetBranchAndLeaf(TBranch *&branch, TL
return false;
}

if (tempDict->IsA() == TDataType::Class() &&
TDictionary::GetDictionary(((TDataType *)tempDict)->GetTypeName()) == fDict) {
if (tempDict->IsA() == TDataType::Class() && fDict->IsA() == TDataType::Class() &&
((TDataType *)tempDict)->GetType() == ((TDataType *)fDict)->GetType()) {
// fLeafOffset = myLeaf->GetOffset() / 4;
branchActualType = fDict;
fLeaf = myLeaf;
Expand Down
28 changes: 28 additions & 0 deletions tree/treeplayer/test/leafs.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,31 @@ TEST(TTreeReaderLeafs, BranchAndLeafWithDifferentNames)
EXPECT_EQ(*rvwithdot, 42);
EXPECT_FALSE(r.Next());
}

// Test for https://github.com/root-project/root/issues/9758
// A TTreeReaderArray of a typedef'd fundamental type (e.g. ULong64_t) must be
// readable through the extended "branch.leaf" syntax, not only through the plain
// branch name. The leaf type name ("ULong64_t") and the reader's resolved type
// name ("unsigned long long") differ, so the leaf/reader match must compare the
// underlying data type, not the dictionary identity.
TEST(TTreeReaderLeafs, ArrayLeafTypedefWithDots)
{
TTree t("t", "t");
Int_t n = 3;
ULong64_t x[3] = {1, 2, 3};
t.Branch("n", &n, "n/I");
t.Branch("x", x, "x[n]/l");
t.Fill();

TTreeReader r(&t);
TTreeReaderArray<ULong64_t> arr(r, "x");
TTreeReaderArray<ULong64_t> arrWithDot(r, "x.x");
ASSERT_TRUE(r.Next());
ASSERT_EQ(arr.GetSize(), 3u);
ASSERT_EQ(arrWithDot.GetSize(), 3u);
for (std::size_t i = 0; i < arr.GetSize(); ++i) {
EXPECT_EQ(arr[i], x[i]);
EXPECT_EQ(arrWithDot[i], x[i]);
}
EXPECT_FALSE(r.Next());
}
Loading