home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!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: <1992Dec22.002957.25597@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: <1992Dec16.201044.2968@microsoft.com> <1992Dec18.193554.18588@ucc.su.OZ.AU> <1gtblgINN72@darkstar.UCSC.EDU>
- Date: Tue, 22 Dec 1992 00:29:57 GMT
- Lines: 71
-
- In article <1gtblgINN72@darkstar.UCSC.EDU> daniel@cse.ucsc.edu (Daniel R. Edelson) writes:
- >
- >> For this reason I think the ARM requirement is unworkable,
- >>and must be modified. The rule should state that pointers
- >>derived from the same object directly in the program must
- >>compare equal. Pointers obtained from the OS need not follow
- >>this rule, in that case it is implementation defined.
- >
- >Neither the C standard nor the C++ standard discusses any OS.
- >(As far as I recall.)
-
- Precisely, nor should they, instead, they ought discuss
- the conditions under which the rule is true, otherwise
- it is implementation defined.
- >
- >A call to the operating system should be viewed as
- >a call to an extension supplied by the language provider.
- >A program that uses an extension can be conforming but
- >not strictly conforming, as per the X3J16 definitions.
-
- Sure. But my interpretation of the p==q rule
- is that any implementation in which it isnt true
- is *non*-conforming. That is, there is no scope in the rule
- for non-strict conformance.
-
- >
- >Thus, I think a better rule is:
- > ``In a strictly conforming program, two pointers
- > to the same object compare equal.''
- >Thus, this property need not be true in any program that
- >calls the operating system.
-
- That is in the spirit of what I wanted, but I'm
- not sure if a standard can say it in those words. Besides,
- I wanted to be more explicit: even if I do an operting
- system call somewhere, I want the system
- to guarrantee
-
- T* p=new T;
- T* q=p;
- if(!(p==q))cout<"Non conforming program";
-
- But I want that
-
- q=alias(p); // OS call to alias pointer
- if(!(p==q))cout<"Not a strictly conforming program";
-
- (Given that p and q point to the same object after aliasing).
- In particular I dont want the above code to render the whole
- program non-conforming.
- >
- >I think actually that ramifications of multiple inheritance
- >and multiple object-addresses should be explicitly addressed
- >in the rule, such as by saying that a pointer to a base-class
- >subobject is not a pointer to the same object as a pointer
- >to the most-derived class object.
- >
- The rule only applies when p and q are the same type.
- If a conversion from a derived to base type occurs a comparison
- would quite correctly yield 1 if the base subobject was a
- sub-object of the complete object.
-
- The other issue is whether empty subobjects are generated
- or not, if they can be, pointers to different subobjects of the
- same type might compare equal.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-