home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!microsoft!hexnut!jimad
- From: jimad@microsoft.com (Jim Adcock)
- Subject: Re: Zero-length structures and pointer comparisons
- Message-ID: <1992Dec16.201044.2968@microsoft.com>
- Date: 16 Dec 92 20:10:44 GMT
- Organization: Microsoft Corporation
- References: <1992Dec10.121935.19315@ucc.su.OZ.AU> <1992Dec11.230534.10499@microsoft.com> <1992Dec15.162202.11231@ucc.su.OZ.AU>
- Lines: 27
-
- In article <1992Dec15.162202.11231@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- |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.
-
- If a strictly conforming implementation is presented with a strictly
- conforming program, then the above works subject to some additional
- constraints, such as a and b refering to disjoint objects.
-
- However, if a strictly conforming implementation is presented with a
- non-strictly conforming program, such as a program that calls OS
- virtual memory mapping adjustment routines, or programs that send
- pointers off the ends of arrays, or programs who don't properly point
- at objects that correspond to the types of objects they pretend to point
- at .... in all such cases all bets are off.
-
-