This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]