home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c++
- Path: sparky!uunet!uunet.ca!frumious!pat
- From: pat@frumious.uucp (Patrick Smith)
- Subject: Re: Zero-length structures and pointer comparisons
- Message-ID: <BzG1Jx.JH@frumious.uucp>
- Date: Fri, 18 Dec 1992 07:16:44 GMT
- Reply-To: uunet.ca!frumious!pat
- References: <1992Dec11.230534.10499@microsoft.com> <1992Dec15.162202.11231@ucc.su.OZ.AU> <1992Dec17.150914.2783@lpi.liant.com>
- Organization: None
- Lines: 44
-
- pkt@lpi.liant.com (Scott Turner) writes:
- |In article <1992Dec15.162202.11231@ucc.su.OZ.AU> John (Max) Skaller writes:
- |It makes me uneasy, but I think Jim Adcock is correct: an implementation
- |can define an extension, such as memory mapping, which overrides the usual
- |execution time rules of C/C++, including the rule that pointers to the same
- |object compare equal. The rule that 1+1==2 would likewise be subject to
- |"extension".
-
- For C, this is my impression also. Although I find the terminology
- unfortunate; it's unsettling to think that a conforming implementation
- could compile and run a conforming program - which could then compute
- 1+1 and get 3.
-
- Has X3J16 adopted similar notions of conformity?
-
-
- |Nevertheless, the C standard implies that the onus is on the invoker of memory
- |mapping to be aware of libraries and other code which may rely on the usual
- |execution time rules of C/C++, such as the rule that pointers to the same
- |object compare equal. If we don't want libraries to make that assumption,
- |then John (Max) Skaller is also correct to say
- |
- |> So the question is really whether the requirement that pointers to
- |> the same object compare equal should be left implementation defined.
-
- Here I would disagree. I think the question is whether, if the C++
- standard adopts the same notions of conformity as the C standard,
- pointers to the same object should be required to compare equal
- in a conforming program.
-
- And the answer is _no_. I hope this requirement would exist for
- _strictly_ conforming programs. And it might be _reasonable_ to
- expect it to hold in conforming programs. But in a conforming
- program which depends on behaviour undefined or unspecified by
- the standard, none of the rules apply, so the standard doesn't
- actually _require_ anything. (It's not clear to me whether all
- rules disappear if a program fails to be strictly programming
- because it depends on implementation-defined behaviour, but it
- doesn't depend on any undefined or unspecified behaviour.)
-
- --
- Patrick Smith
- uunet.ca!frumious!pat
- pat%frumious.uucp@uunet.ca
-