I've seen a puzzle while surfing. It is given below.
I think, the problem is related to pointer type conversion. I don't have a 64-bit processor. I was unable to fully elaborate it.
Please explain why does this program behaves differently on different architectures.
Thanks.
The following C program segfaults of IA-64, but works fine on IA-32.
Why does it happen so?
Code:
int main()
{
int* p;
p = (int*)malloc(sizeof(int));
*p = 10;
return 0;
}
Please explain why does this program behaves differently on different architectures.
Thanks.
Comment