Yes, Fortran compilers should assume that pointers can be an alias with other pointers and with target
variables.
If you have pointer arrays a
and b
, then in
a(i) = a(i) + b(i)
the compiler should assume that these two arrays may partially overlap and it should block certain optimizations, since changing the value of a
may change some value of b
at some unknown index.
See also the C restrict
keyword and a more in-depth discussion in Is Fortran optimized better than C for heavy computing? . Do not repeat all the points associated with the pointer alias raised there.
IanH's comment was intentionally, perhaps too strong, but it contains a lot of truth.
source share