Skip to content

[flang][docs] Add note about Cray pointers and the TARGET attribute #137993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions flang/docs/Aliasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,30 @@ Fortran also has no rule against associating read-only data with a pointer.
Cray pointers are, or were, an extension that attempted to provide
some of the capabilities of modern pointers and allocatables before those
features were standardized.
They had some aliasing restrictions; in particular, Cray pointers were
not allowed to alias each other.

They are now more or less obsolete and we have no plan in place to
support them.
They had some aliasing restrictions; in particular, Cray pointers were not
allowed to alias each other.

In this example, `handle` aliases with `target`.

```
integer(kind=8) :: target(10)
integer(kind=8) :: ptr
integer(kind=8) :: handle(10)
pointer(ptr, handle)
target = 1
ptr = loc(target)
print *, target
end
```

Optimizations assume that Cray pointers do not alias any other variables.
In the above example, it is assumed that `handle` and `target` do not alias,
and optimizations will treat them as separate entities.

In order to disable optimizations that assume that there is no aliasing between
Cray pointer targets and entities they alias with, add the TARGET attribute to
variables aliasing with a Cray pointer (the `target` variable in this example).

## Type considerations

Expand Down
Loading