From -6206986516936531349
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-12-19 15:59:34 PST
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: <1992Dec18.193554.18588@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: <1992Dec11.230534.10499@microsoft.com> <1992Dec15.162202.11231@ucc.su.OZ.AU> <1992Dec16.201044.2968@microsoft.com>
Date: Fri, 18 Dec 1992 19:35:54 GMT
Lines: 42

In article <1992Dec16.201044.2968@microsoft.com> jimad@microsoft.com (Jim Adcock) writes:
>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;
>|	}
>|
>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.  
>
	I know what you are saying but dont see it.
ARM p74:"two pointers to the same object compare equal".
Any program for which this is not true cannot be conforming,
neither strictly nor non-strictly, it is non-conforming, it is
not in fact a C++ program.

	Or have I got this wrong?

	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.
This is the case for pointers way off the end of an array:
it is implementation defined.

	(When I say 'derived' from the same object, I 
am defering the exact definition :-)

-- 
;----------------------------------------------------------------------
        JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
	Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------


