> The function is quite complicated
And you wanted us to extrapolate your problem from just 3 lines of code?
Myriad are the ways it could be messed up.
I'm guessing that this is proprietary code, so there's no way for you to post it.
> It's hard to explain, but seems to start with variable (static data) corruption.
Start with nearby static arrays, and look for overruns.
Can you refactor
Code:
int fnc ( int arg ) {
// whole mess of code
return result;
}
Into
Code:
int fnc_part1 ( ) {
// half a mess of code
}
int fnc_part2( ) {
// the other half a mess of code
}
int fnc ( int arg ) {
fnc_part1();
return fnc_part2();
}
You might be able to figure out which part is the problem.
You didn't even tell us which compiler.