Re: floating point exception with a loop

From: Rene BRUN <rene.brun_at_cern.ch>
Date: Wed, 02 Mar 2005 09:00:12 +0100


Alexis,

I do not understand the problem with your example. With the if(0) the block should not be executed ! Anyhow, assuming that you run with if(1) you should replace the line

     const int N = ntuple->GetEntries();//it is the origin the error by

     const int N = (int)ntuple->GetEntries();//it is the origin the error

Note that your code with

     float newindex[3][N];
will work with CINT and some versions of gcc, but is unlikely to work elsewhere. You should allocate your array dynamically.

Rene Brun

Alexis Cothenet wrote:
>
> Hi all,
>
> I have seen something very strange using the 4.02 ROOT binary version.
>
> I have a macro test1.C:
>
> void test1(){
> gROOT->ProcessLine(".L test2.C");
> for (int i=0;i<1;i++){
> DoCalib("coucou");
> }
> }
>
> and test2.C :
> int DoCalib(char * a_filename){
> if(0){
> TFile *f = new TFile(a_filename,"UPDATE");
> TNtuple *ntuple = (TNtuple*)f->Get("dataSP2");
> const int N = ntuple->GetEntries();//it is the origin the error message
> // const int N = 5;//works well with that!
> float newindex[3][N];
> for (int Z=0;Z<3;Z++){
> for (int Y=0; Y<N ;Y++){
> newindex[Z][Y] = -1.0;
> }
> }
> }
> return 0;
> }
>
>
> When i run .L test1.C then test1()
> i have the problem :
> *** Break *** floating point exception
> Root > Function test1() busy flag cleared
> Function DoCalib() busy flag cleared
>
>
> The problems is coming from the definition
> of "const int N" in test2.C
>
> If i put const int N = 5, it works well.
> And if i let const int N = ntuple->GetEntries()
> but in test1.C, put DoCalib("coucou");
> without any loop, it works well...
>
> Does someone has an idea in order i could let my macro test1.C with a
> loop ?
>
> Thanks very much in advance.
>
> Regards,
> Alexis
>
>
Received on Wed Mar 02 2005 - 09:00:17 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET