From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Tue, 5 Jan 2016 12:40:25 -0800 To: 9fans@9fans.net Message-ID: In-Reply-To: References: <8edba5d726ee6a032d8521c7de33f499@felloff.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] subtracting pointers on amd64 6c Topicbox-Message-UUID: 7e70d4f0-ead9-11e9-9d60-3106f5b1d025 On Tue Jan 5 11:49:06 PST 2016, charles.forsyth@gmail.com wrote: > 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 && yes! this. one thing i love about the plan 9 compilers is that my reasonable expectations are not violated by some happy optimizer, or decision. this gets us back to the op's pov > i get that probably nobody cares about c standards here, but it might > be useful to mention what c99 and c11 say about this issue, since the which i think is wrong. there is some current silliness with compilers that conflates allowed with required and undefined with can be deleted. i see plan 9's decisions as rejecting this way of thinking. however, this is in no way anti-standard. - erik