Message from discussion
Questions about pointer comparisons
Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: Keith Thompson <ks...@mib.org>
Newsgroups: comp.lang.c
Subject: Re: Questions about pointer comparisons
Date: Tue, 01 Dec 2009 17:03:45 -0800
Organization: None to speak of
Lines: 26
Message-ID: <lniqcq191q.fsf@nuthaus.mib.org>
References: <39474e22-259a-448f-9ba4-f3d1a8de099d@m3g2000yqf.googlegroups.com> <7nkgshF3lna8iU1@mid.uni-berlin.de> <87638qo1b9.fsf@temporary-address.org.uk> <ln8wdm2yju.fsf@nuthaus.mib.org> <17d6a4f2-c98c-4d84-a536-c1ce3a619c86@v25g2000yqk.googlegroups.com> <lnvdgq1e52.fsf@nuthaus.mib.org> <20091201163906.278@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.eternal-september.org U2FsdGVkX1+2kdQnlBgqN1ee6IBDdvw58YXzU9MBzTpMZQw57ef+4peY+GrnJmkIjgaZUaR9RAQP5AVzz4W1YLd4PKODHC9TY2PaZokMsJFd6tx5qaDkfuqeppLTJlCb
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Wed, 2 Dec 2009 01:06:01 +0000 (UTC)
X-Auth-Sender: U2FsdGVkX1+1kPF6HynvWFthOCK/8rap
Cancel-Lock: sha1:ggPXODsgssNrPyMeKMJqfXtDq8E=
sha1:S7pQKcfbY3Z/Mn5ElLIfXvYV6ZE=
User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/21.4 (gnu/linux)
Kaz Kylheku <kkylh...@gmail.com> writes:
> On 2009-12-01, Keith Thompson <ks...@mib.org> wrote:
>> If the language required "<" and ">" to work consistently for pointer
>> values (i.e., for any two valid pointers p1 and p2, exactly one of
>> (p1 < p2), (p1 == p2), and (p1 > p2) is true, along with the other
>> usual consistency requirements), then the "<" and ">" operators
>> *would* have to do all that work.
>
> Which means that code targetting 8086 machines would be larger and slower,
> having to normalize segment:offset values rather than blindly comparing
> them as 32 bit words.
>
> When C was standarized, this architecture was widespread, and used
> as a target for C programming. Standardizing pointer inequality would have
> codified code that didn't work on MS-DOS, at least in some memory models.
>
> This issue is now worth revisiting.
Agreed (except that I think you meant relational operators, not
inequality).
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"