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

Stack not reset correctly when have structure returned from function array

We have C compilers version 4.03 and was wondering if any compiler versions after this has this problem.

We have a function array set up to point to functions that return a structure. We have found that the stack is not cleaned up after returning from a function on this array.

The code would be something like this:

typedef struct
{
int value;
boolean status;
} struct_Results;

typedef struct_Results (*funcptr)(void);

const funcptr functarray[] =
{
GetFirstValue,
GetSecondValue,
GetThirdValue,
GetFourthValue
};

Then in the function:

int loop;
struct_Results results[4];

for ( loop = 0; loop < 4; loop++ )
{
results[loop] = functarray[loop];
}

The stack is off coming back from any one of these calls and the offset is times 4 since this function array is called 4 times.

Has anyone else experienced this problem?

Thanks,
Rick Brown