This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to implement `restrict' in C
- To: mark at markmitchell dot com, egcs-patches at cygnus dot com
- Subject: Re: PATCH to implement `restrict' in C
- From: Richard Henderson <rth at cygnus dot com>
- Date: Sat, 10 Oct 1998 14:24:54 -0700
- Cc: Jeff Law <law at cygnus dot com>
- References: <199810092015.NAA13687@smtp.earthlink.net>
- Reply-To: Richard Henderson <rth at cygnus dot com>
On Fri, Oct 09, 1998 at 01:15:28PM -0700, Mark Mitchell wrote:
> int* restrict i;
> int* restrict j;
> int* k;
>
> we know that `i' and `j' cannot point to the same thing, but either
> might alias the storage point to by `k'.
This was not my understanding of the definition of restrict.
My understanding is that it is intended to signify that that
pointer contains the _only_ reference to a block of memory.
Quoting n2620.pdf (whatever version of the c9x draft that was):
~~~~~
4 During each execution of [block] B, let A be the array object that is
determined dynamically by all references through pointer expressions
based on [the restricted pointer] P. Then _all_ [emph theirs] references
to values of A shall be through pointer expressions based on P.
...
7 1. The file scope declarations
int * restrict a;
int * restrict b;
extern int c[];
assert that if an object is referenced using the value of one of a,
b, or c, then it is never referenced using the value of either of
the other two.
~~~~~
This makes restrict significantly easier to implement than
you make out. None of the subset bits should be necessary.
r~