Strange Bug: loop counter not incrementing in for loop
Hi, recently I got stuck up with possibly the strangest bug while programming in C in Ubuntu. The pseudo-code is as follows:
main(){
int a;
.
.
.
fun1(a);
.
.
}
void fun1(int a){
int y;
.
.
//Creates double linked lists and calls several other functions (that are working fine)
.
.
//Several lines below, I am calling this function
x=fun2(y);
.
.
}
int fun2(int y){
int i;
.
.
for(i=0; i<2;i++){
if(y==0){
//Do something
}
.
.
}
.
.
}
So the problem is: The variable 'i' in 'fun2' is not incrementing, As a result, the program is getting stuck in an infinite loop in this for loop in fun2.
Somebody said that these are the issues that are dependent on the linux distribution and the compiler I am using. I did not try this program on any other distribution (I will do it soon). I am using gcc compiler.
Can anybody help me in this issue? Thanks in advance.
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask D.V.S. Phanindra for more information if necessary.