This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Parameter pass bug ??

The following code works in Carm Compiler and it doesn't work in Realview Compiler !!
What's happening ?

char func(char x1, char x2)
{
 return(x1+x2);
}

char teste(char c1, char c2)
{
 func(4,5);
 return (c1+c2); // in this point c1 and c2 crashed !!
}

int main(void)
{
 teste(1,2);
 while(1);
}

  • Define what you mean by does not work. I executed this code, and teste(1,2) returns 3. If what you mean is that the debugger gets confused, you are right. At the line return(c1+c2), the debugger reports c1 as 9 and c2 as 5. I am not sure why, but the debugger is still beleiving that r0 and r1 contain the values of c1 and c2 (which was true when the function was entered, but have since been overwritten by the call and return from func()). However, the code does behave properly. I am hopeing that Keil will provide a fix for this confusing situation.

  • You are right!
    Debugger gets confused !
    I was believing in the debugger!