Segmentation fault in a method created by rootcint

Dear all,

I have a problem concerning a segmentation fault in code created by
rootcint (ROOT Version 4.01-02):

I have the example class MyExampleContainer with the header file


#include <stdlib.h>
#include “TObject.h”

class MyExampleContainer : public TObject {


Float_t dummyfloat;
Int_t dummyint;


and the implementation

#include “MyExampleContainer.hh”
#include "TObject.h"
dummyint = 0;
dummyfloat = 0;

and the LinkDef file

#ifdef CINT
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class MyExampleContainer;

Then I create a dictionary with

$ROOTSYS/bin/rootcint -f MyExampleContainerDict.cpp -c
MyExampleContainer.hh MyExampleContainerLinkDef.h

I use the class in the following context:

BtoXsGammaFile = new TFile (rootfilename.c_str(), “RECREATE”, “B to Xs
Gamma Selection Root File”);
// then define the contents of the tree by hand:
BtoXsGammaTree = new TTree(“BtoXsGammaTree”,“B0 -> Xs Gamma Fully Inclusive”);
// and now the objects in the tree:
testHeader = new MyExampleContainer();
ErrMsg(routine) << “creating branch MyExampleContainer” << endmsg;
TestBranch = BtoXsGammaTree->Branch(“Test”, “MyExampleContainer”,
testHeader, 64000,1 );
ErrMsg(routine) << “returning from branch MyExampleContainer” <<

which compiles and links without any problems. When I run it I get a
segmentation fault in


which is a method in the dictionary file created by rootcint. It is called from TTree::Branch.
(An example code (not a very sensible one, I just plugged it into a code which was originally creating an ntuple, since the original code where the problem first occuerd is much too large to distribute it) can be found at
(There might be minor differences in there from the example above, but the problem stays the same))

Can anyone please tell me the probably incredibly silly error that I am
making? :wink:

Thank you very much,

TestBranch = BtoXsGammaTree->Branch("Test", "MyExampleContainer", testHeader, 64000,1 );
Should be

TestBranch = BtoXsGammaTree->Branch("Test", "MyExampleContainer", &testHeader, 64000,1 );
Branch requires the address of a pointer (and not the value of the pointer).