From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29671 invoked by alias); 18 Oct 2002 23:20:23 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 29640 invoked from network); 18 Oct 2002 23:20:20 -0000 Received: from unknown (HELO plum.csi.cam.ac.uk) (131.111.8.3) by sources.redhat.com with SMTP; 18 Oct 2002 23:20:20 -0000 Received: from student.cusu.cam.ac.uk ([131.111.179.82] helo=kern.srcf.societies.cam.ac.uk ident=mail) by plum.csi.cam.ac.uk with esmtp (Exim 4.10) id 182gPk-0004bP-00; Sat, 19 Oct 2002 00:20:20 +0100 Received: from jsm28 (helo=localhost) by kern.srcf.societies.cam.ac.uk with local-esmtp (Exim 3.35 #1 (Debian)) id 182gPk-0005x0-00; Sat, 19 Oct 2002 00:20:20 +0100 Date: Fri, 18 Oct 2002 18:46:00 -0000 From: "Joseph S. Myers" X-X-Sender: To: Joe Buck cc: Subject: Re: restrict keyword [was: expalin this syntax pls] In-Reply-To: <200210181741.g9IHfBt04104@piper.synopsys.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-10/txt/msg01159.txt.bz2 On Fri, 18 Oct 2002, Joe Buck 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. 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. -- Joseph S. Myers jsm28@cam.ac.uk