This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/35721] ASSOCIATED returns false when strides confusing
- From: "dick dot hendrickson at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Mar 2008 00:57:07 -0000
- Subject: [Bug fortran/35721] ASSOCIATED returns false when strides confusing
- References: <bug-35721-15620@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from dick dot hendrickson at gmail dot com 2008-03-28 00:57 -------
Subject: Re: ASSOCIATED returns false when strides confusing
On 27 Mar 2008 18:27:44 -0000, burnus at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #1 from burnus at gcc dot gnu dot org 2008-03-27 18:27 -------
> Confirm. Note NAG f95 complains the program is invalid and I think it is right:
>
> Error: Explicit interface required for MG0028 from TRY_MG0028 - argument TDA2R
> (no. 1) is a TARGET
>
Yes, you (and NAG) are correct. Originally, the subroutine was in a big module
and when I cut it out I did the quick and dirty thing of merely
calling it without
thinking. For what it's worth, the other g compiler I tried this on
also got the wrong
answer and didn't complain about the interface.
Dick Hendrickson
> But this does not solve the gfortran problem ;-)
>
> From the standard: (v) applies here, but (vii) is analog - except that TARGET
> is a pointer instead of a target.
>
> "Case (v): If TARGET is present and is an array target, the result is true if
> the target associated with POINTER and TARGET have the same shape, are neither
> of size zero nor arrays whose elements are zero-sized storage sequences, and
> occupy the same storage units in array element order. Otherwise, the result is
> false. If POINTER is disassociated, the result is false."
>
> gfortran is failing since in dimension 1 they have different strides:
> Pointer: 2:1:-2 (namely: element 2)
> Target: 2:2:1 (namely: element 2)
>
> However, libgfortran/intrinsics/associated.c only checks whether the stride is
> the same. Proposed patch:
>
> Index: libgfortran/intrinsics/associated.c
> ===================================================================
> --- libgfortran/intrinsics/associated.c (Revision 133633)
> +++ libgfortran/intrinsics/associated.c (Arbeitskopie)
> @@ -48,10 +48,12 @@ associated (const gfc_array_void *pointe
> rank = GFC_DESCRIPTOR_RANK (pointer);
> for (n = 0; n < rank; n++)
> {
> - if (pointer->dim[n].stride != target->dim[n].stride)
> + long extent;
> + extent = pointer->dim[n].ubound - pointer->dim[n].lbound;
> +
> + if (extent != (target->dim[n].ubound - target->dim[n].lbound))
> return 0;
> - if ((pointer->dim[n].ubound - pointer->dim[n].lbound)
> - != (target->dim[n].ubound - target->dim[n].lbound))
> + if (pointer->dim[n].stride != target->dim[n].stride && extent != 0)
> return 0;
> if (pointer->dim[n].ubound < pointer->dim[n].lbound)
> return 0;
>
>
> --
>
> burnus at gcc dot gnu dot org changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |burnus at gcc dot gnu dot
> | |org
> Status|UNCONFIRMED |NEW
> Ever Confirmed|0 |1
> Last reconfirmed|0000-00-00 00:00:00 |2008-03-27 18:27:43
> date| |
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35721
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35721