[PATCH] C undefined behavior fix
dewar@gnat.com
dewar@gnat.com
Fri Jan 4 14:17:00 GMT 2002
<< When casting from pointer to integer and back again, the resulting
pointer must reference the same object as the original pointer, otherwise
the behavior is undefined. That is, one may not use integer arithmetic
to avoid the undefined behavior of pointer arithmetic as proscribed
in 6.5.6/8.
>>
That seems clear enough to me, and would say clearly that the code in
question *is* undefined. Now Linus appears to claim that the above is
inconsistent with the C standard, but I don't follow his argument that
this is the case (and I do not agree with the conclusion).
More information about the Gcc
mailing list