From 5643985969776382691
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e94695845965b249
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1992-10-28 05:41:48 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: <1992Oct28.181926.23375@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: <23978@alice.att.com> <1992Oct23.064817.2648@ucc.su.OZ.AU> <1992Oct24.044422.28435@athena.mit.edu>
Date: Wed, 28 Oct 1992 18:19:26 GMT
Lines: 47

In article <1992Oct24.044422.28435@athena.mit.edu> jfc@athena.mit.edu (John F Carr) writes:
[On two pointers comparing equal on segmented machines]

>I don't think this is a concern for either C or C++.  While it is possible
>to set up several aliases for the same data, I can think of no reason for
>a language implementation to provide multiple aliases for the same data
>when only standard language facilities are used.

	I can. Suppose the language implementation decided to
protect 'const' objects by aliasing all pointers to const, so that
a violation caused a hardware fault. Thus

	const char *x=new char[100]; 
	char *y=(char*)x; // cast away const

Now access through x is physically protected (for unknown reasons,
perhaps to preserve 'const' in machine code routines) but access
is allowed through y. But now x!=y unless special care is taken.
This is illegal at the moment because we have two different
pointers to the same object.
>
>For example, an 80386 may choose to map the stack and data segments so
>there is partial overlap, but any reference to the stack via the data
>segment (or to the static data via the stack segment) would be via
>non-portable constructions like casting an integer to a pointer.  Any
>object would have a fixed segment associated with it even though it might
>be possible to access it via a different segment.
>

	For foreign interfacing there are many issues not addressed
by the language. The language conceives a single task with a single
address space. Yet C++ is *used* in other circumstances. One cannot
write an OODBMS server or GUI app without violating  this concept. But 
arguments from implementers of such things in favour of downcasting
for example are considered to have some merit.

	I call the native single address space type program
a "domestic" program (not invented by me though). Unfortunately,
it does not serve well for many applications. One must 'trick'
the language---often.


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


