🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2905

Re: pointer comparison

#2905
From: der Mouse
Date: Wed, 23 Dec 1992 16:56
31 lines
1652 bytes
Well, it's been a couple of days, and I'm about to leave, and *nobody*
has replied (as far as our news server knows), so I'll stick my neck
out in public again....

In article <18221@autodesk.COM>, larsn@Autodesk.COM (Lars Nyman) writes:

> I *think* there is language in the standard that says something to
> the effect that comparisons of pointers to two objects that are NOT
> members of the same aggregate or union object is undefined (with one
> exception - one or both pointers pointing past the last object of an
> array).

The actual situation is close.  For the time being, let us consider
pointers pointing one element past the end of an array as actually
pointing into that array.  With that proviso, pointer comparison using
<, <=, >, or >= is undefined when the two pointers don't point into the
same object.

Pointer comparison using == or != is always well-defined, and the
pointers compare equal exactly when they point to the same thing (and
!= is the complement of ==).

> So, if I have two different objects of same type, and they are not in
> the same array or aggregate, the result of comparing pointers to them
> is undefined !!???

Yes, except with == or !=.

					der Mouse

			    mouse@larry.mcrcim.mcgill.edu
Technical Details
Message-ID: <1992Dec23.165636.10674@thunder.mcrcim.mcgill.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
References: <18221@autodesk.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
Newsgroups: comp.std.c
Subject: Re: pointer comparison
Message-ID: <1992Dec23.165636.10674@thunder.mcrcim.mcgill.edu>
Date: 23 Dec 92 16:56:36 GMT
References: <18221@autodesk.COM>
Organization: McGill Research Centre for Intelligent Machines
Lines: 32