If you use the keyword auto in the interpreter, it doesn’t correctly return (or at least print out the pointer) of the correct object. Bit of a gotcha.
For example, I have two instances of a class called Model loaded from two open files. I have a DataLoader class that handles the branch addresses etc. In any case, new DataLoader() creates a new member Model*.
root [1] DataLoader* dl = new DataLoader("r11-test3.root")
(DataLoader *) 0x7fe5e5485bf0
root [2] DataLoader* dl2 = new DataLoader("r11-test3b.root")
(DataLoader *) 0x7fe5e54dedc0
root [3] auto mt = dl->GetModelTree()
(TChain *) @0x7ffeed30a038
root [4] auto mt2 = dl2->GetModelTree()
(TChain *) @0x7ffeed30a038 //< WRONG
root [5] mt->GetEntry(0)
(int) 2085
root [6] mt2->GetEntry(0) //< which one am I accessing?
(int) 2085
root [7] auto mod = dl->GetModel()
(Model *) @0x7ffeed30a038
root [8] auto mod2 = dl2->GetModel()
(Model *) @0x7ffeed30a038 //< WRONG
The second one gets the wrong object (on input 4). Using an explicit type though (same session, same variables), it does:
thanks for reporting this strange problem! I have opened a GitHub issue for it with a simple reproducer:
It seems that the pointer are actually still pointing to the correct object, it’s just that the interpreter prints out something wrong. So you can proceed with auto if you don’t care about the prints, or just use auto * which works as expected. So I hope you can continue working with that until one of our interpreter experts will take care about the issue on GitHub?