Article View: comp.std.c++
Article #4Re: Zero-length structures and pointer comparisons
From: John MAX Skaller
Date: Wed, 28 Oct 1992 18:19
Date: Wed, 28 Oct 1992 18:19
47 lines
2814 bytes
2814 bytes
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 ------------------
Technical Details
Message-ID:
<1992Oct28.181926.23375@ucc.su.OZ.AU>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtalReferences:
<23978@alice.att.com> <1992Oct23.064817.2648@ucc.su.OZ.AU> <1992Oct24.044422.28435@athena.mit.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!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