[Patch, fortran] PR32962 - b = conjg(transpose(a)) is erroneous if b is an allocatable array

Paul Thomas paulthomas2@wanadoo.fr
Sun Aug 12 11:42:00 GMT 2007


:ADDPATCH fortran:

This problem turns out not to be anywhere near as specific as the title 
indicates.  The Bugzilla entry comment #10 points out that b does not 
have to be an allocatable array; any array whose expression has no shape 
will do - eg.an assumed shape array.  Also, any elemental intrinsic will 
do; eg cos instead of conjg.

The error comes about because the scalarizer decides to make the loops 
zero based for this assignment.  Since gfc_conv_array_transpose 
transfers the source offset to the result, regardless of the base for 
the loops, the error is inevitable.  The patch detects zero based loops 
and sets the offset to zero.  As far as I can tell, this is the only 
array intrinsic that has this behaviour.  The testscase is based on the 
reporter's, although I used real(8) and cos(), instead of complex(8) and 
conjg().

Regtested on amd64/Cygwin_NT - OK for trunk?

Paul

2007-08-12  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/32962
    * trans-array.c (gfc_conv_array_transpose): Set the offset
    of the destination to zero if the loop is zero based.

2007-08-12  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/32962
    * gfortran.dg/transpose_1.f90: New test.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr32962.diff
Type: text/x-patch
Size: 3437 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070812/1d71b7a1/attachment.bin>


More information about the Fortran mailing list