*** Break *** segmentation violation when using
unique_ptr on TTree:
root  auto theTree = std::make_unique<TTree>("myTree","MyTestTree")
root  .q
Is this a glitch?. It doesn’t happen the same if I use
Thanks a lot
ROOT Version: v6-14-04
as per ROOT’s historical ownership rules, a TTree created like that will belong to the current
gDirectory. At teardown, both the
unique_ptr and the
TTree, causing the crash.
There is an easy solution in v6.14 though, that was put in place exactly to avoid these kind of issues: you can tell the TTree to not register in any
TDirectory, like this:
auto theTree = std::make_unique<TTree>("myTree","MyTestTree", /*splitlevel=*/99, /*dir=*/nullptr);
where splitlevel 99 is simply the default value.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.