🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1152

Re: Zero-length structures and pointer comparisons

#1152
From: Jim Adcock
Date: Thu, 24 Dec 1992 00:52
33 lines
1919 bytes
In article <1992Dec20.201212.8974@lth.se> dag@bellman.control.lth.se (Dag Bruck) writes:
|The goal was to write data structures that use the ordering of
|pointers to improve search time.  What I need is mechanism that
|compares the pointers -- what they actually point to is not relevant.

On the contrary, you DO NOT then need such a mechanism, because alternate
approaches not using pointers can give you similar improvements to search times.

|C and C++ has some notion of equality between pointers.  You can
|clobber the semantics of this equality with memory mapping and what
|not, but that is in my view an issue beyond the language.

Agreed, as long as *you* stick to the C and C++ notion of equality
between pointers -- which is an extremely limited notion of equality.

|I would finally like to return to a claim I made earlier, but nobody
|has commented on (as far as I know).  I belive that even if you
|imposed a total ordering on pointers in a segmented architecture
|(e.g., Inte 8086 family), compilers would be able to handle the
|follwing common case efficiently:
|
|	void zap(int* a, unsigned n)
|	{
|		for (int* p = a; p < a+n; p++)
|			*p = 0;
|	}
|
|and produce the same code as today (without the total ordering).
|After all, the assignment "p = a" says that "p" must point to the same
|segment as "a".  Any comments?

You statement is true, but does not imply your intended conclusion, 
namely that thus one can efficiently implement total ordering.
Technical Details
Message-ID: <1992Dec24.005201.1488@microsoft.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad
References: <1992Dec18.204337.3084@lth.se> <1992Dec19.202043.20366@ucc.su.OZ.AU> <1992Dec20.201212.8974@lth.se>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!microsoft!hexnut!jimad
From: jimad@microsoft.com (Jim Adcock)
Subject: Re: Zero-length structures and pointer comparisons
Message-ID: <1992Dec24.005201.1488@microsoft.com>
Date: 24 Dec 92 00:52:01 GMT
Organization: Microsoft Corporation
References: <1992Dec18.204337.3084@lth.se> <1992Dec19.202043.20366@ucc.su.OZ.AU> <1992Dec20.201212.8974@lth.se>
Lines: 33