TFileMerger fails, error message incorrect

I trying to use the TFileMerger to merge some files that my Geant4 simulation have created. The simulation is distributed, so the shape of the outputs are identical, and merging should be easy. Using the hadd.C example works flawlessly, but the TFileMerger, which I think should be superior to hadd.C, fails completely. Below the output.

[code][TFile::Cp] Total 0.01 MB |====================| 100.00 % [18.3 MB/s]
Warning in TClass::TClass: no dictionary for class TH1F is available
Warning in TClass::TClass: no dictionary for class TH1 is available
Warning in TClass::TClass: no dictionary for class TAxis is available
[TFile::Cp] Total 0.01 MB |====================| 100.00 % [21.4 MB/s]
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1
Error in TClass::New: cannot create object of class TH1

*** Break *** segmentation violation
Fatal in TFileMerger::RecursiveRemove: Output file of the TFile Merger (targeting test.root) has been deleted (likely due to a TTree larger than 100Gb)
aborting
Aborted (core dumped)
[/code]

The TTree size isn’t the problem, my files are a few kb’s. I’ve tried to compare hadd.C and TFileMerger::MergeRecursive, but comprehending the difference is unfortunately well outside my expertise.

Attached a minimum viable example that creates the above output.
bugreport.zip (32.7 KB)

Try to modify your “main”: ... #include "TApplication.h" ... int main() { TApplication a("a", 0, 0); // for autoloading of ROOT libraries ...
Also, using “uint” is not portable. You’d better use “UInt_t” or simply “unsigned int”.

Yup, that seems to have fixed it! Thanks. Can you tell me why this mattered? I suppose this sets some state that the tfilemerger constructor doesn’t set itself.