View Single Post
Old 10-24-2012, 12:09 PM   #10
dentin
Member
 
Join Date: Apr 2008
Home MUD: Alter Aeon
Posts: 245
dentin is on a distinguished road
Re: Need help with RPI-Engine

Actually Camlorn, the pointer rules are pretty strict on that one: x will always point at a[4] (pointer addition uses structure sizes.)

Did you mean instead:

char *y = (char *)a
y = y+4
int *x = (int *)y

That could put you in the middle of an integer on a 64 bit machine, and dereferencing x could give you an alignment exception depending on architecture type.

Regardless, I think your original point is made even more clear by this: pointers in C can be complicated and are poorly understood, often leading to catastrophic yet unobvious mistakes.

-dentin

Alter Aeon MUD
dentin is offline   Reply With Quote