This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: dewar at gnat dot com
- To: rth at redhat dot com, torvalds at transmeta dot com
- Cc: gcc at gcc dot gnu dot org, trini at kernel dot crashing dot org
- Date: Fri, 4 Jan 2002 17:16:58 -0500 (EST)
- Subject: Re: [PATCH] C undefined behavior fix
<< 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).