Thank you for reporting this bug. I figured out what is happening and fixed it
.
Cint tries to compile inner and outer loops at the first execution. But the
bytecode compiler has a limitation for array element initialization. It should
stop compilation and void the bytecode. But, there was a bug when you have
array initialization inside outer loop.
I fixed the problem in the latest version. This is an easy change. You can
patch the source code by yourself. In $CINTSYSDIR/src/pcode.c, remove line
5133.
src/pcode.c line 5133
/* if(G__ASM_FUNC_NOP==G__asm_wholefunction) G__no_exec_compile=0; */
Masaharu Goto
---------------------------------------------------------------
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