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: PR 25512: pointer overflow defined?


Gabriel Dos Reis wrote:

you can (equality) compare a pointer to NULL -- which does not even
happen to designate an object.


Well accurately, you can compare pointers, its not illegal, but the result of
comparing pointers to separately allocated objects is undefined.


[...]

| One way to think about the semantic model is to consider pointers
| in C to consist of a base/offset pair, where the base points to the
| start of the object (some debugging checkout C compilers even
| use such a format). Then operations on pointers need ONLY
| reference the offset.

that model is too simplistic -- hint: null pointers.


null is a special case indeed, which can be reprsented using a distinguished offset

-- Gaby






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