Path: ...!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.arch Subject: Re: Computer architects leaving Intel... Date: Wed, 11 Sep 2024 17:34:38 -0700 Organization: A noiseless patient Spider Lines: 43 Message-ID: <86bk0thfq9.fsf@linuxsc.com> References: <2024Aug30.161204@mips.complang.tuwien.ac.at> <86r09ulqyp.fsf@linuxsc.com> <2024Sep8.173639@mips.complang.tuwien.ac.at> <2024Sep10.101932@mips.complang.tuwien.ac.at> <86frq6gnn3.fsf@linuxsc.com> <20240911195221.00004881@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Thu, 12 Sep 2024 02:34:40 +0200 (CEST) Injection-Info: dont-email.me; posting-host="62297a80a79ef9d9a88587ce28522bc2"; logging-data="4087470"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lMHv84yvOsn3zf2HzgUF7ZRtjinNJ8k0=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:td5ZFSbawC6r0VdSoTl2MKUvkWk= sha1:j9Svco6TImAKllSolJCBW+yDLO0= Bytes: 3337 Michael S writes: > On Wed, 11 Sep 2024 09:29:04 -0700 > Tim Rentsch wrote: > >> Josh Vanderhoof writes: >> >> [how to write a portable, UB-free check if mempcy() intervals overlap] >> >>> It is legal to test for equality between pointers to different >>> objects >> >> Right. This observation is the key insight. > > Real mode x86 C compilers operating in Large and Compact Models that > were popular on IBM-compatible PCs 30-40 years ago could have more than > one representation for the pointer to the same memory location. If my > memory serves me, the rules of pointers comparison for equality were > the same as rules of comparison for <>. In both cases for reliable > result pointers had to be explicitly normalized (i.e. converted from > 'far' to 'huge' or something like that). > > It was long time ago and even back then I didn't use Large model very > often, so it's possible that I misremember. But if I remember > correctly, does it mean that those C compilers now would be considered > non-compliant? The C standard was first ratified (by ANSI) in 1989. The rules for pointer comparison were clarified in the C99 standard, but it has always been true that pointers to the same object have to compare equal. C environments that have things like 'far' or 'huge' pointers, etc, are not standard C but must have extensions so that they can deal with the different kinds of pointers. Depending on how the non-standard kinds of pointer worked, the implementation might or might not be conforming. Most likely though it's a moot point because once a program starts using an extension all the rules can change, and the C standard allows that. It's only programs that look like really standard C that have to do what the C standard says (for the implementation to be conforming); any code that declares a 'far' pointer or 'huge' pointer certainly isn't standard C.