Data typing problem
Mar. 20th, 2007 07:25 pmvoid foo(size_t *f) { *f = 1; }
int main() { long l = 0; int i = 0; arch(); foo((size_t *)&l); foo((size_t *)&i); printf("l = %ld (size = %d)\n" "i = %ld (size = %d)\n", l, sizeof(long), i, sizeof(int)); }
This works as expected on the Intel platforms (using both gcc and vendor compilers):
machine: i686 l = 1 (size = 4) i = 1 (size = 4)
And:
machine: ia64 l = 1 (size = 8) i = 1 (size = 4)
But, wouldn't you know it, it behaves differently on my target platform:
machine: SX-6 l = 4294967296 (size = 8) i = 1 (size = 4)
So, my question is, which behaviour is correct? The behaviour on Intel or on the SX? The former, I suspect. I'm desperately hoping that there's some sort of compiler flag that I can use to fix the problem on the SX because I really, really don't want to have recode — the application is riddled with this stuff.