<div dir="ltr">Hello David,<div><br></div><div>I think adding an option which analogous to -fwrapv is a good candidate for addressing the concern.<br></div><div>Well, I didn't know that arithmetic on intptr_t was implementation defined - I thought the arithmetic on intptr_t is equivalent to the integer types. Thanks for the point.</div><div><br></div><div>Juneyoung Lee</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 16, 2019 at 9:40 AM David Chisnall <<a href="mailto:David.Chisnall@cl.cam.ac.uk">David.Chisnall@cl.cam.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 15/01/2019 16:26, Juneyoung Lee wrote:<br>
> If C programmer wants to get distance between two different objects, <br>
> s/he can use (intptr_t)p - (intptr_t)q instead of p - q.<br>
<br>
That's fine for new code, but unless you're volunteering to audit the <br>
(roughly) 8 billion lines of open source C code and a corresponding <br>
(probably larger) amount of proprietary code, then making this <br>
assumption is going to break things.<br>
<br>
From the relatively small survey that we did of C idioms as part of the <br>
CHERI project, I can tell you that this is very widespread. This was <br>
something that we had to support (we considered only allowing pointer <br>
subtraction to yield a valid result when the operands referred to the <br>
same object and it broke pretty much everything we looked at).<br>
<br>
David<br>
<br>
P.S. If you want to talk about the standard with respect to intptr_t, <br>
you might want to reread what the standard actually says about it, <br>
specifically that a) it's optional, and b) if it does exist the only <br>
operation that is guaranteed to work is a cast from a pointer to an <br>
intptr_t and back again - all arithmetic on intptr_t is implementation <br>
defined.<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><br></div><font size="1">Juneyoung Lee</font><div><font size="1">Software Foundation Lab, Seoul National University</font></div></div></div>