public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Alexander Monakov <amonakov@ispras.ru>
Cc: <gcc-patches@gcc.gnu.org>, Richard Biener <rguenther@suse.de>
Subject: Re: [PATCH] doc: clarify the situation with pointer arithmetic
Date: Wed, 22 Jan 2020 01:29:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.21.2001220111280.21353@digraph.polyomino.org.uk> (raw)
In-Reply-To: <alpine.LNX.2.20.13.2001211527540.32566@monopod.intra.ispras.ru>

On Tue, 21 Jan 2020, Alexander Monakov wrote:

> My intent was more basic. I observed that the paragraph can be interpreted as
> saying that if you have a cast 'I1 = (intptr_t) P1', then perform some
> computations on I1 that do not in any way depend on values of other pointers,
> then casting the result back can not point to a different object than P1.

Yes.  I don't think the wording in the existing standard (where anything 
other than casting the same integer value back to pointer type - and, 
furthermore, the result is only specified to compare equal to the original 
pointer, not to be otherwise usable in place of it) can distinguish that 
version (PVI) from PNVI.

> But that is not very helpful, because this is the case where the user 
> might have used normal pointer arithmetic in the first place.

I think a typical use case of intptr_t might be e.g. masking off low bits 
of a pointer value for alignment while remaining within the same object.  
Another one might be to compare pointers to different objects in 
implementing memmove-like functions, where ordered pointer comparison 
would not be defined in ISO C.

> I think that the case discussed in the proposed patch is already not ambiguous
> and does not need further clarifications to the standard.

I don't think such a requirement for PNVI can be deduced from the existing 
text.

-- 
Joseph S. Myers
joseph@codesourcery.com

      parent reply	other threads:[~2020-01-22  1:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 15:50 Alexander Monakov
2020-01-20 21:53 ` Sandra Loosemore
2020-01-20 23:11   ` Alexander Monakov
2020-01-21  0:44 ` Joseph Myers
2020-01-21 13:57   ` Alexander Monakov
2020-01-21 14:59     ` Richard Biener
2020-01-21 15:08       ` Alexander Monakov
2020-01-22  8:04         ` Richard Biener
2020-01-22 12:09           ` Martin Sebor
2020-01-23 13:47             ` Richard Biener
2020-01-24  0:06               ` Uecker, Martin
2020-01-27 15:14                 ` Richard Biener
2020-01-28  4:02                   ` Uecker, Martin
2020-01-28  8:28                     ` Alexander Monakov
2020-01-28 10:16                       ` Richard Biener
2020-01-28 13:28                         ` Uecker, Martin
2020-01-29  9:01                           ` Richard Biener
2020-01-29 14:28                             ` Uecker, Martin
2020-01-30  9:47                               ` Richard Biener
2020-01-30 14:42                                 ` Uecker, Martin
2020-01-30 16:59                                   ` Michael Matz
2020-01-30 17:27                                     ` Michael Matz
2020-01-30 17:29                                     ` Uecker, Martin
2020-01-31  9:31                                       ` Richard Biener
2020-01-31 12:26                                         ` Uecker, Martin
2020-01-31 13:22                                           ` Richard Biener
2020-01-28 13:08                       ` Uecker, Martin
2020-01-28 18:04                         ` Alexander Monakov
2020-01-22  1:37       ` Joseph Myers
2020-01-22  8:15         ` Richard Biener
2020-01-22  1:29     ` Joseph Myers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.2001220111280.21353@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).