This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: restrict keyword [was: expalin this syntax pls]


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]