[ROOT] Segmentation fault in loop with mask

From: Ranpal Singh Dosanjh (Ranpal.Singh.Dosanjh@cern.ch)
Date: Mon Apr 08 2002 - 23:00:21 MEST


Dear rooters,

I have a bizarre segmentation fault which I am trying to understand, and 
I hope someone can help me.  I've reduced the problem to the following
macro:

{
  gROOT->Reset();

  Int_t i=1;
  Int_t n = 3;
  Int_t mask[n]={0,0,1};

  for (i=0;i<n;i++) {
      if (mask[i]) {
              TString hello = "hello";
              cout << hello << endl;
      } 
  }

}

This results in a segmentation fault.  However, if mask is, say, {1,0,1},
then there is no segmentation fault, and the macro behaves as expected. 
In fact, the only configuration of mask elements for which a segmentation
fault occurs is zero in the first element and at least one non-zero
element. 

I'm running root 3.02/07 on Linux, if it makes a difference.

Thanks,

Ranpal



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:48 MET