From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <8edba5d726ee6a032d8521c7de33f499@felloff.net> Date: Tue, 5 Jan 2016 19:46:35 +0000 Message-ID: From: Charles Forsyth To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=047d7bae4696ca646305289b7ebf Subject: Re: [9fans] subtracting pointers on amd64 6c Topicbox-Message-UUID: 7e53b15e-ead9-11e9-9d60-3106f5b1d025 --047d7bae4696ca646305289b7ebf Content-Type: text/plain; charset=UTF-8 On 5 January 2016 at 19:01, Devon H. O'Dell wrote: > so given any of the examples in this thread, if you typedef'ed > ptrdiff_t to long, then the compiler technically isn't actually doing > anything wrong. whether it is doing something useful is a different > question. > Well, although I knew that was true, I didn't want to push the point because in practice, people have a right to expect certain reasonable behaviour, and it's quite reasonable to expect that p+(q-p) yields q if they both point into the same array that the system agreed to allocate somehow. It make sense to use 64 bits for the difference, and indeed the code block that adds the current cast has an if(1 && ...) suggesting an if(0 && ... to be inserted instead. It would have been better if I'd simply named it by enum and added a comment to explain some of this. There are some effects on library interfaces that I didn't mention earlier, but since 64-bit operation should now be as common as not (allowing for 32-bit ARM), it makes sense to update everything to cope with it properly. --047d7bae4696ca646305289b7ebf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On 5 January 2016 at 19:01, Devon H. O'Dell <devon.odell@gmail.com= > wrote:
so given any of the examples in this= thread, if you typedef'ed
ptrdiff_t to long, then the compiler technically isn't actually doing anything wrong. whether it is doing something useful is a different
question.

Well, although I knew that was tr= ue, I didn't want to push the point because
in practice, people have a right to expect certain reasonable behaviou= r,
and it's quite reasonable to expect = that p+(q-p) yields q if they both point
in= to the same array that the system agreed to allocate somehow.
It make sense to use 64 bits for the difference, and ind= eed the code
block that adds the current ca= st has an if(1 && ...) suggesting an if(0 && ...
to be inserted instead. It would have been better if = I'd simply named it by enum and
added a= comment to explain some of this.

There are some effects on library interfaces th= at I didn't mention earlier, but
since = 64-bit operation should now be as common as not (allowing for 32-bit ARM),<= /div>
it makes sense to update everything to cope= with it properly.
--047d7bae4696ca646305289b7ebf--