IHEP, Protvino, Russia, 27-APR-1998 Dear friends! I have the following code: { // Example 1 TFile *root_file = new TFile("a.root","RECREATE", "file",9); TTree *tree = new TTree("tree","tree"); root_file->Write(); root_file->Map(); root_file->Print(); root_file->Close(); // Close root file. delete tree; // here! delete root_file; } produces next output: TFile Writing Name=a.root Title=file 980427/160834 At:64 N=86 TFile 980427/160835 At:150 N=104 TTree CX = 2.71 980427/160835 At:254 N=90 TFile 980427/160835 At:344 N=54 TFile TFile: name=a.root, title=file, option=CREATE ****************************************************************************** *Tree :tree : tree * *Entries : 0 : Total Size = 104 bytes File Size = 104 * * : : Tree compression factor = 1.00 * ****************************************************************************** *** Break *** segmentation violation Why "segmenation violation"? If I remove string "delete tree;" the message "*** Break *** segmentation violation" disappears. The following code works well: { // Example 2 TFile root_file("a.root","RECREATE", "file",9); TTree tree("tree","tree"); root_file->Write(); root_file->Map(); root_file->Print(); root_file->Close(); // Close root file. } Why code 'Example 1' with new-delete operators is bad? Thanks in advanced, Alexander Zvyagin.
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:32 MET