This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Cray Pointer validity question


On 9/9/10 3:31 AM, "Tobias Burnus" <burnus@net-b.de> wrote:
>   Dear Asher, dear all,
> 
> the attached test case - a stripped down version of
> gfortran.dg/cray_pointers_2.f90 - fails (with -O3) if one applies the
> patch at http://*gcc.gnu.org/ml/fortran/2010-09/msg00170.html
> 
> The reason is that pointee and intarr alias in parmptre - but the
> routine does not know this. The question is: Is this actually valid code?
> 
> If I apply the patch patch, it works. Is this now a test-suite bug? Or
> does one need to handle this?

The test itself is buggy, somewhat intentionally. Since iptee is an alias
for iarray, the code is inherently unsafe; the optimizer assumes that no
such aliasing occurs.  Here's the relevant snippet from the manual:

----
"Cray pointees often are used to alias an existing variable.  For example:

             integer target(10)
             integer iarr(10)
             pointer (ipt, iarr)
             ipt = loc(target)
 
As long as ipt remains unchanged, iarr is now an alias for target. The
optimizer, however, will not detect this aliasing, so it is unsafe to use
iarr and target simultaneously.  Using a pointee in any way that violates
the Fortran aliasing rules or assumptions is illegal. It is the user's
responsibility to avoid doing this; the compiler works under the assumption
that no such aliasing occurs."
----

Unfortunately, it's difficult to test Cray pointers without resorting to
breaking this rule, and my best recollection about this test is that I was
trying to trick the optimizer with the common block /foo/foo and the
function intne.  Now the optimizer has caught up.  Can these tests be
compiled and run only at -O0?  That would be sufficient to regression-test
the basic Cray-pointer functionality.

-Asher


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