Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Setting architectural features in stone Date: Mon, 01 Aug 2016 11:44:33 -0700 Organization: None to speak of Lines: 47 Message-ID: References: <373211b1-a3c7-4b42-85d7-0862cc962b08@googlegroups.com> <20160728165021.72543369@maxa-pc> <7d408a14-4549-4816-9289-e99c79e16427@googlegroups.com> <0755a071-225c-4c54-9f3b-58f76e8387f0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="22390"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19SIWRq278438v+/Iy9N0KW" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:IBZorqWWz4qgz7mplBuuZzUVCcI= sha1:w8hW/eehwAXTZW8mcOBlyQ6MCXo= Xref: csiph.com comp.lang.c:91510 supercat@casperkitty.com writes: > On Monday, August 1, 2016 at 12:21:09 PM UTC-5, Keith Thompson wrote: >> supercat writes: >>> On Monday, August 1, 2016 at 11:26:56 AM UTC-5, Ivan Godard wrote: >>>> Unclear what this bullet means for any machine... Equality is >>>> consistent with relationals. >>> >>> On compact-model or large-model 8086 compilers, it was common for pointer >>> relational comparisons to examine only the offset part of an address >>> while ignoring the segment. If one had two pointers, p and q, located at >>> addresses 0x0100:0x1234 and 0x0200:0x1234, then the comparions p<=q, >>> p>=q, and p!=q would all be true; the other comparison operators would all >>> report false. >> >> I'm not sure how the various 8086 memory models work(ed) in practice, >> but as far as the C standard is concerned, if p and q point to >> different objects then `p != q` must yield 1 (true). The relational >> operators (<, <=, >, >=) can examine only the offset parts of their >> operands, since if the prefixes differ the behavior is not defined. >> But the equality and inequality operators must correctly tell you >> whether two pointers point to the same object -- which means in >> this case that they must examine the entire pointer values (and >> perhaps perform some normalization if needed). >> >> I'd be surprised if real-world 8086 compilers didn't handle this >> correctly. > > I didn't claim 8086 compilers didn't handle that in accordance with > the Standard. I had indicated that commonplace general-purpose > microcomputer compilers implemented the relational operators so as to > report a consistent ordering among *all* pointers (including those > for which the standard would impose no requirements), but such ordering > was not necessarily consistent with the equality operators. I was > offering up the 8086 as an example of an architecture that behaved in > a fashion where the relational ordering could be inconsistent with the > equality operators. My apologies, I misread what you wrote. Your description is consistent with the requirements of the C standard, and with what I would have expected. (I don't think I'd call that a "consistent ordering". I might call it a consistent partial ordering.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"