Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Is this really necessary Date: Tue, 10 Aug 2021 11:41:06 -0700 Organization: None to speak of Lines: 42 Message-ID: <871r71f8hp.fsf@nosuchdomain.example.com> References: <86im0h2fi1.fsf@linuxsc.com> <3rwQI.20474$6p.6686@fx36.iad> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e"; logging-data="29950"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bDWd2vCA1UWuRWBzqO3Ug" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:mj1zCGk0JAbSixgIiUavRjGcYl8= sha1:lhbtSig/LKwANY57qzjTmSuFnJ4= Xref: csiph.com comp.lang.c++:80841 scott@slp53.sl.home (Scott Lurndal) writes: > Juha Nieminen writes: >>Alf P. Steinbach wrote: >>> True, but. `std::less` & family impose a total order on pointers of the >>> same type, where for directly comparable pointers (i.e. within the same >>> array or single-object-as-size-one-array) that order is the same as the >>> `<` order. That implies that internally these functions compute some >>> absolute representation of pointers, mapping segment selectors to lower >>> level addresses as necessary. >> >>Since pointers, like any object, by necessity have a bit representation, >>they can be compared and strictly ordered. > > I would argue against the latter part of your > statement by referring to various extant > and future architectures where your statement is not true, some of > which even have C compilers. > > I'm familiar with one extant architecture (Clearpath) where pointers > are not as you describe, and one potential future architecture > (which is currently under NDA, but similar to the CHERI research > project) where the pointers are not simple > offsets from the start of memory. I think what he meant is that since pointers have a bit-level representation, it's always possible to have a strict ordering of that representation. The ordering isn't necessarily semantically meaningful, but sometimes it can be useful to have a *meaningless* total ordering, as long as it's consistent. Having said that, if a pointer value can have two or more different bit representations, you can't do even a semantically meaningless total ordering unless you can impose some kind of canonical representation. Presumably that's what makes implementing std::less potentially complicated (though it's likely to be almost trival for most implementations). -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for Philips void Void(void) { Void(); } /* The recursive call of the void */