Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Michael S Newsgroups: comp.arch Subject: Re: Computer architects leaving Intel... Date: Thu, 12 Sep 2024 14:10:33 +0300 Organization: A noiseless patient Spider Lines: 50 Message-ID: <20240912141033.00006dd1@yahoo.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> <86bk0thfq9.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Thu, 12 Sep 2024 13:10:10 +0200 (CEST) Injection-Info: dont-email.me; posting-host="795ae34dc5508363080905c3d099c810"; logging-data="248937"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZwpP9iGcoudzvldtmUNRYYbeYJYN6xII=" Cancel-Lock: sha1:SzEHDYbMLBrd+VYO/6IALgaYQUc= X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32) Bytes: 3636 On Wed, 11 Sep 2024 17:34:38 -0700 Tim Rentsch wrote: > 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. In Compact and Large models data pointers are 'far' by default. So, the source doesn't have to use non-standard declarations.