public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joe Buck <jbuck@synopsys.com>
To: jsm28@cam.ac.uk (Joseph S. Myers)
Cc: Joe.Buck@synopsys.COM (Joe Buck), gcc@gcc.gnu.org
Subject: Re: restrict keyword [was: expalin this syntax pls]
Date: Fri, 18 Oct 2002 21:53:00 -0000	[thread overview]
Message-ID: <200210190012.g9J0CDh07290@piper.synopsys.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0210190016180.21524-100000@kern.srcf.societies.cam.ac.uk> from "Joseph S. Myers" at Oct 19, 2002 12:20:16 AM

I wrote:
> > Consider rtest.c
> > -----------------------------------------------
> > void f(const int* restrict pci, int* restrict pi);
> > 
> > int main()
> > {
> > 	int n;
> > 	f(&n, &n);
> > }
> > -----------------------------------------------
> > 
> > This is not a legal program: f's arguments are restricted pointers,
> > meaning that we promise the compiler that there is some data that
> > can be accessed only through pci, and other data that can be accessed
> > only through pi, yet we pass the same value to both pointers.

Joseph S. Myers writes:
> It's a perfectly legal program if f doesn't actually write through pi
> (missing an optional const).  Remember that the definition of restrict was
> changed substantially between the last public draft and the FDIS (at the
> instigation of the UK) to a model where there can be readonly access
> through multiple restricted pointers unless the data is written to.

This means that we can't issue a hard error for it, but a warning may well
still be appropriate.  Errors are for code that is wrong, warnings are for
code that is likely to be wrong. If you insist on not issuing warnings for
such code, we have the problem that we can't use similar mechanisms to
warn about possible misuse of memcpy, whose specification implies
"restrict" even for C++, which doesn't have the keyword.


  reply	other threads:[~2002-10-19  0:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-17 23:32 expalin this syntax pls Nathan .
2002-10-18  4:23 ` Jim Wilson
2002-10-18 14:27   ` restrict keyword [was: expalin this syntax pls] Joe Buck
2002-10-18 18:46     ` Joseph S. Myers
2002-10-18 21:53       ` Joe Buck [this message]
2002-10-18 21:55         ` Joseph S. Myers
2002-10-18 23:07     ` kwall
2002-10-19 10:17 Erik Schnetter

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=200210190012.g9J0CDh07290@piper.synopsys.com \
    --to=jbuck@synopsys.com \
    --cc=Joe.Buck@synopsys.COM \
    --cc=gcc@gcc.gnu.org \
    --cc=jsm28@cam.ac.uk \
    /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).