This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C undefined behavior fix
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Linus Torvalds <torvalds at transmeta dot com>
- Cc: <rth at redhat dot com>, Tom Rini <trini at kernel dot crashing dot org>, <gcc at gcc dot gnu dot org>
- Date: Fri, 4 Jan 2002 22:01:51 +0000 (GMT)
- Subject: Re: [PATCH] C undefined behavior fix
On Fri, 4 Jan 2002, Linus Torvalds wrote:
> The thing is, pointer expressions outside the area may be "undefined
> behaviour", but the same is NOT true if you cast the thing to an
> unsigned long or similar. At that point it is _implementation_ defined
> what the result is, and gcc has clear guidelines on what the
> int->pointer conversion is.
The GCC implementation defines pointer-integer-pointer conversion to be
undefined if you go outside the object. See the mainline manual:
http://gcc.gnu.org/onlinedocs/gcc/Arrays-and-pointers-implementation.html
This is related to the general questions about provenance of pointer
values discussed in DR#260.
http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_260.htm
--
Joseph S. Myers
jsm28@cam.ac.uk