You are making a basic C++ mistake. When exiting from the function gimeFinalCut thestd::vector that you created inside is automatically deleted.
You should use new instead.
Unfortunately I don’t have currently ROOT debug libraries and can’t really play with the debugger. So maybe I am mistaking, but it seems, a double deletion happens…
[quote=“brun”]You are making a basic C++ mistake. When exiting from the function gimeFinalCut thestd::vector that you created inside is automatically deleted.
You should use new instead.
Rene[/quote]
He doesn’t use a reference, so I think it is a copy, which will be returned and even RVO will do its job (copy operation will not be performed - optimized out). So there should be no mistake here, maybe only design things.
Or I’ve just overlooked something?
I was aware of this, but I don’t see why it is a mistake. The vector
I created was intended only for temporary use within that function.
I knew it would be deleted by leaving the function but why should that
cause a crash? I assume the destructor of vector will delete all its
elements, which is fine with me as well, leaving aside the issue
of performance/speed.
I actually tried to compile and run the very same code, just
replacing TCut with a basic type, e.g. int, or some other simple
class, and it works.
CINT has problems with interpreting vector. Please create a dictionary for it by putting the following lines into the file vecTCutDict.C:
[code]#include “TCut.h” #include
#ifdefMAKECINT #pragma link C++ class vector+; #endif
[/code]
and run .L vecTCutDict.C+
.x test.C You can also put the line gROOT->ProcessLine(".L vecTCutDict.C+"); into your test() / gimeFinalCut() function.