Restricted Pointers
Tom MacDonald
uunet!fig.cray.com!tam
Fri Nov 15 12:00:04 PST 1991
> Subject: Restricted pointers
>
> The problem with restricted pointers can be described by the
> following.... can you pass it on to Tom (Just the example below)
> and see what he thinks.
>
> I think the whole thing is dangerous to programmers and hard for
> compilers to safely take full advantage of the aliasing information
> (especially when inlining).
>
> Consider this example :
>
> main () {
> int a[10];
>
> a[5] = 42;
> { int * restrict r; /* function inlined at source level */
> r = a;
> r[5] = 7; /* assign to "unique associated array" */
> }
> if (a[5] == 42) printf ("This case is undefined\n");
> }
>
> Comments are welcomed.
>
> These are not IBM's views, these are the personal ones of:
> Fred Tydeman, IBM, Austin, Texas (512) 838-3322; fax (512) 838-3484
> Internet: tydemanaibmpa.awdpa.ibm.com uucp: uunet!ibmsupt!tydeman
Sorry for taking so long to respond to this issue. I also owe
Dave Hough and Peter ShenKin a response. The intent of the
Restricted Pointer Proposal is to state that the above program
is well-defined. The formal definition states that a block scope
restricted pointer only has unique access as long as it is in scope.
In the above example the pointer `r' is the only mechanism used to
modify array `a' within the block where `r' is declared. Undefined
behavior exists only when *both* `a' and `r' are used to modify the
same array in the same block. It is also the intent of the
restricted pointer proposal to allow function inlining and restricted
pointers to coexist in a natural way. The definition of restricted
pointers was modeled after behavior granted by the Fortran-77 standard.
Fortran-77 allows extensive subroutine inlining without aliasing.
In Fortran-77 each dummy argument is, in effect, a restricted pointer
that has exclusive access to its associated object. Therefore, a
restrcited pointer declared at block scope is like a dummy argument in
an inlined Fortran subroutine.
If the formal definition does not capture this intent then there is
a problem with the formal definition and it should be fixed. However,
it is my opinion that the formal definition does capture this intent.
Tom MacDonald
tamacray.com
uunet!cray!tam
More information about the Numeric-interest
mailing list