C
candy
hi all,
Consider the following C code:
void funct(){
}
int main(){
int x;
x=funct;
printf("%x\n",x);
return 0;
}
It prints the address of the function funct().It means that
the function funct() is in the process stack even before it is
called.So,it should be safe to call setjmp in the function
funct() in the following way:
jmp_buf env;
int funct(){
if(setjmp(env)==1)
printf("called by longjmp\n");
return 0;
}
int main(void){
funct();
longjmp(env,1);
return 0;
}
On execution,the above program crashes.Can anybody please tell me
that what is the problem.
Thanks.
Consider the following C code:
void funct(){
}
int main(){
int x;
x=funct;
printf("%x\n",x);
return 0;
}
It prints the address of the function funct().It means that
the function funct() is in the process stack even before it is
called.So,it should be safe to call setjmp in the function
funct() in the following way:
jmp_buf env;
int funct(){
if(setjmp(env)==1)
printf("called by longjmp\n");
return 0;
}
int main(void){
funct();
longjmp(env,1);
return 0;
}
On execution,the above program crashes.Can anybody please tell me
that what is the problem.
Thanks.