Curt Stienstra

Problems returning pointers in optimized code

Discussion created by Curt Stienstra on Feb 22, 2007
Latest reply on Feb 22, 2007 by Ken Johnson
I was trying to return a pointer from a function and was getting some strange results.

char *LookUpPtr(int selector)
{
char *addr;

addr = /* some math */
return addr;
}

I turned Optimizations Off and it started to work. Anyone know how to fix this?


I was able to pass the pointer via:

void LookUpPtr(int selector, char **ptr)
{
char *addr;

addr = /* some math */
*ptr = addr;
}


I’m using CodeWarrior Development Studio for ColdFire Architectures Version 6.3 (Preview Release) and targeting the MCF52233 Coldfire.

Thanks,
Curt

Outcomes