Re: CINT problem?

From: Faouzi Attallah (attallah@clri6a.gsi.de)
Date: Sun Nov 15 1998 - 16:08:44 MET


Dear Mike,

It is only a C++ programing problem. If you are Fortran programmer try
just this (as it is, without int main ()}, it is working

 {
   int u, np = 20 ;
   double *xd = (double *) calloc(np, sizeof(double)) ; 
   //or 
   //double xd[20]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.}

   for(int i=0;i<5;i++){
     printf("Loop number %d\n",i);

     if(4>5)  { //always false

       for(u=0; u < np; u++)   // could be used with "double xd[20] ;" see bellow
	 xd[u] =  0. ;
       
       for( u=0; u<1; u++)
	 printf("Inside test loop\n");
       
       printf("This should not be printed\n");
       
     } //if block
     
   } //for loop
 }


 F. Attallah 
GSI mbH 
Planckstr 1
D-64291 Darmstadt 
  Tel: +49 (0)6159 71 2142 
  Fax: +49 (0)6159 71 2901
Email: F.Attallah@gsi.de

On Sat, 14 Nov 1998, Mike Heffner wrote:

> Hello,
> 
> 	I am quite new to root and C++.  I am having trouble understanding
> what CINT is doing.  CINT will execute code in blocks that it should not
> enter.  The following is an example; 
> 
> ---------------------------------------
> int main(){
> 
> for(int i=0;i<5;i++){
>   printf("Loop number %d\n",i);
> 
>   if(4>5) { //always false
> 
>     double xd[20]={0};   // this casues problems
> 
>     for(int u=0;u<1;u++){printf("Inside test loop\n");}
>     printf("This should not be printed\n");
> 
>   } //if block
> 
> } //for loop
> return 0;
> }
> ------------------------------------------
> 	The if statement is always false.  So, I understand that code in
> that block should never be executed?  If I compile this with a regular C++
> compiler (g++) it works as I expect.  If I run this same code with CINT, I
> get something I don't understand.  The first time through the first for
> loop, I get the printed statement from the line "printf("This should not
> be printed\n");". 
> 	I have found that if I remove either of the two lines,
> 
>    double xd[20]={0};   // this casues problems
>         
>     for(int u=0;u<1;u++){printf("Inside test loop\n");}
> 
> the problem goes away.  Could someone explain to me what is happening
> here?
> 
> Thanks,
> Mike Heffner
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:39 MET