🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4277

Re: Pointer comparisons 2

#4277
From: Stephen Baynes
Date: Thu, 26 Oct 1995 08:41
36 lines
1965 bytes
Clive D.W. Feather (clive@stdc.demon.co.uk) wrote:
: In article <46cu3i$6fg@solutions.solon.com>,
: Daniel Villeneuve <danielv@CRT.UMontreal.CA> wrote:
: > I know that the _result_ of comparing two pointers that do not belong to
: > the same array is undefined.

: No. The comparison is allowed to fail in some horrible way, not even
: returning a result. Certainly it doesn't have to return a *consistent*
: result.

And to give some rationale to this take segmented architectures. Here
the comparison operators only need to compare the offset in segment, not
the segment id [this is with the restriction that an object cannot be larger
than a segment.] This is more efficient as it saves having to do a comparison
of the segment id. The equality operators do need to check the segment id as
well.

For example if 'a' is 101:25 and 'b' is 120:25  ( <segment-id>:<offset> )
then:
       a != b                   #segment if checked
       a <= b      
       a >= b      
       !( a = b )               #segment id checked
       !( a > b  )
       !( a < b  )

which is not much use as an ordering.

It is a bit annoying that there is no full ordering on pointers as are a 
number of occasions it would be useful.

--
Stephen Baynes                              baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton                                 My views are my own.
United Kingdom
Technical Details
Message-ID: <DH1s52.77x@ukpsshp1.serigate.philips.nl>
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
References: <46cu3i$6fg@solutions.solon.com> <46ke8p$soo@solutions.solon.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
Subject: Re: Pointer comparisons 2
Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
Message-ID: <DH1s52.77x@ukpsshp1.serigate.philips.nl>
Date: Thu, 26 Oct 1995 08:41:26 GMT
References: <46cu3i$6fg@solutions.solon.com> <46ke8p$soo@solutions.solon.com>
Organization: Philips Semiconductors, Southampton, UK
X-Newsreader: TIN [version 1.2 PL2]
Followup-To: comp.std.c