home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Zero-length structures and pointer comparisons
- Message-ID: <1992Dec15.162202.11231@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Dec8.173855.18153@meaddata.com> <1992Dec10.121935.19315@ucc.su.OZ.AU> <1992Dec11.230534.10499@microsoft.com>
- Date: Tue, 15 Dec 1992 16:22:02 GMT
- Lines: 46
-
- In article <1992Dec11.230534.10499@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
- >In article <1992Dec10.121935.19315@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >| The answer to this particular question is YES, they must
- >|compare equal according to the ARM. And I think this is a problem
- >|for OS design for the 386, for example, where the memory management
- >|kernel will just have to ignore the ARM.
- >
- >No more nor less than any other virtual memory OS that allows
- >multiply mapped pages. Since there is no functionality in the
- >language requiring such multiply mapped pages, you only get in
- >this situation by invoking some system dependency, in which case
- >you are making use of implementation dependencies. If you will,
- >a common C/C++ implementation defined extension to the language
- >is to allow the use of OS calls in order to map various regions
- >of memory to the same underlying page, allowing the same object
- >to be accessed via differing addresses. Implementation defined,
- >no more nor less.
- >
-
- But Jim, it is not implementation defined, it is required that
- pointers to the same object compare equal. It is therefore
- legal to have a function:
-
- f(X* a, X*b) {
- if(a==b) { /* special case, copy b object */ ... }
- else *a+=*b;
- }
-
- where the += operation is destructive and wont work if a and b point
- to the same object. The above code is guarranteed in C++, but
- will fail on a suitably organised system. It is therefore not
- allowed to do this sort of memory mapping in C++ behind the scenes,
- which is what I'm concerned with...we actually want to.
-
- So the question is really whether the requirement that pointers to
- the same object compare equal should be left implementation defined.
- Or perhaps more restrictions be made, like saying they must
- compare equal if one is assigned from another, but not otherwise.
-
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-