home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!spool.mu.edu!yale.edu!ira.uka.de!math.fu-berlin.de!mailgzrz.TU-Berlin.DE!cs.tu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!sunic!news.lth.se!dag
- From: dag@bellman.control.lth.se (Dag Bruck)
- Newsgroups: comp.std.c++
- Subject: Re: Zero-length structures and pointer comparisons
- Message-ID: <1992Dec20.201212.8974@lth.se>
- Date: 20 Dec 92 20:12:12 GMT
- References: <BzCG7K.2sG@frumious.uucp> <1992Dec18.192202.17023@ucc.su.OZ.AU> <1992Dec18.204337.3084@lth.se> <1992Dec19.202043.20366@ucc.su.OZ.AU>
- Sender: news@lth.se
- Organization: Department of Automatic Control, Lund, Sweden
- Lines: 40
-
- In <comp.std.c++> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >>>
- >>>In fact, p==q iff objects equal is unimplementable on some machines.
- >>>That is, even the existing ARM requirement is unworkable.
- >
- >Perhaps we can conceive two types of pointers, type 1
- >provides no comparisons at all, type 2 allows equality test.
-
- I think we're sliding away from the original discussion.
-
- 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.
-
- Let me try to put it differently: the element type is "pointer to X",
- not "X" itself.
-
- 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.
-
- 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?
-
- -- Dag
-
-
-