Hello Gregory and Rene, Thank you for reporting this problem. It turns out that this is a bug of Cint which is a little bit complicated. void f(const int n) { int a[n]; // size of a varies each time f() is called. } Cint's bytecode compiler does not support above case. This is not simple to fix quickly. The code should be compiled as follows in spite of how it looks. void f(const int n) { int *a = new int[n]; ... delete[] a; } Please give me time to think about this. Masaharu Goto >Date: Thu, 1 Mar 2001 23:51:25 +0100 (MET) >From: Rene Brun <Rene.Brun@cern.ch> >To: Gregory Novak <Gregory.Novak@cern.ch> >Cc: roottalk@pcroot.cern.ch, rootdev@pcroot.cern.ch >Subject: CINT: Re: [ROOT] Strange seg faults > >Hi Greg, >This seems to be a CINT optimization problem. >It runs with optimisation level 3 or below but not with level 4 >select >root > .O3 > >I am forwarding the problem to Masa. > >Rene Brun > >On Thu, 1 Mar 2001, Gregory Novak wrote: > >> I'm using Root 2.25.03 and I'm getting segmentation faults I don't >> understand. This has something to do with array allocation and >> function arguments. I'm loading a bunch of c++ code via .L, containing >> the following two functions: >> >> void profMedian2(Float_t x[], Float_t y[], const Int_t nBins) { >> for (Int_t i=0; i<nBins; i++) { >> sliceMedian2(x,y,nBins); >> } >> } >> >> Float_t sliceMedian2(Float_t x[], Float_t y[], const Int_t n) { >> Float_t sortedX[n]; >> return 0; >> } >> >> Then I have the following in a macro. >> { >> Float_t x[500]; >> Float_t y[500]; >> profMedian2(x, y, 500); >> } >> >> When I run the macro, Root gives me a segmentation fault. There are a few >> things that are confusing: The seg fault comes when root tries to call >> sliceMedian2, but I can run it directly without trouble. If I change the >> arguments of sliceMedian2 or profMedian2, the seg fault goes away. Also, >> if I take out the for loop around the call to sliceMedian2, the seg fault >> goes away. This is in spite of the fact that the seg fault comes on the >> first pass through the loop. >> >> So, is there any solution to this? >> >> Thanks! >> Greg >> >> >> >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:38 MET