public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/35721] New: ASSOCIATED returns false when strides confusing
@ 2008-03-27 16:49 dick dot hendrickson at gmail dot com
2008-03-27 18:28 ` [Bug fortran/35721] " burnus at gcc dot gnu dot org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dick dot hendrickson at gmail dot com @ 2008-03-27 16:49 UTC (permalink / raw)
To: gcc-bugs
The ASSOCIATED functions returns false for the 4th test below. It
should return true. there have been a ton of interps and rewording
of the associated function. It's probably clearer to read
case (v) in the F2003 standard.
program try_mg0028
! fails on Windows XP
! gcc version 4.4.0 20080312 (experimental) [trunk revision 133139]
real tda2r(2,3)
call mg0028(tda2r, 1, 2, 3)
end
SUBROUTINE MG0028(TDA2R,nf1,nf2,nf3)
real, pointer :: TLA2L(:,:),TLA2L1(:,:)
real, target :: TDA2R(NF2,NF3)
logical LL(4)
TLA2L => TDA2R(NF2:NF1:-NF2,NF3:NF1:-NF2)
TLA2L1 => TLA2L
LL(1) = ASSOCIATED(TLA2L)
LL(2) = ASSOCIATED(TLA2L,TLA2L1)
LL(3) = ASSOCIATED(TLA2L,TDA2R)
LL(4) = ASSOCIATED(TLA2L1,TDA2R(2:2,3:1:-2)) !should be true
if (any(LL .neqv. (/ .true., .true., .false., .true./))) then
print *, LL
print *, shape(TLA2L1)
print *, shape(TDA2R(2:2,3:1:-2))
endif
END SUBROUTINE
C:\g_experiments\gfortran>gfortran m
g0028.f
C:\g_experiments\gfortran>a
T T F F
1 2
1 2
--
Summary: ASSOCIATED returns false when strides confusing
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dick dot hendrickson at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35721
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/35721] ASSOCIATED returns false when strides confusing
2008-03-27 16:49 [Bug fortran/35721] New: ASSOCIATED returns false when strides confusing dick dot hendrickson at gmail dot com
@ 2008-03-27 18:28 ` burnus at gcc dot gnu dot org
2008-03-28 0:57 ` dick dot hendrickson at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-03-27 18:28 UTC (permalink / raw)
To: gcc-bugs
------- 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
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/35721] ASSOCIATED returns false when strides confusing
2008-03-27 16:49 [Bug fortran/35721] New: ASSOCIATED returns false when strides confusing dick dot hendrickson at gmail dot com
2008-03-27 18:28 ` [Bug fortran/35721] " burnus at gcc dot gnu dot org
@ 2008-03-28 0:57 ` dick dot hendrickson at gmail dot com
2008-03-28 13:48 ` burnus at gcc dot gnu dot org
2008-03-28 13:50 ` burnus at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: dick dot hendrickson at gmail dot com @ 2008-03-28 0:57 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/35721] ASSOCIATED returns false when strides confusing
2008-03-27 16:49 [Bug fortran/35721] New: ASSOCIATED returns false when strides confusing dick dot hendrickson at gmail dot com
2008-03-27 18:28 ` [Bug fortran/35721] " burnus at gcc dot gnu dot org
2008-03-28 0:57 ` dick dot hendrickson at gmail dot com
@ 2008-03-28 13:48 ` burnus at gcc dot gnu dot org
2008-03-28 13:50 ` burnus at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-03-28 13:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2008-03-28 13:47 -------
Subject: Bug 35721
Author: burnus
Date: Fri Mar 28 13:47:06 2008
New Revision: 133684
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133684
Log:
2008-03-28 Tobias Burnus <burnus@net-b.de>
PR fortran/35721
* intrinsics/associated.c (associated): Ignore different
stride of pointer vs. target if only one element is referred.
2008-03-28 Tobias Burnus <burnus@net-b.de>
PR fortran/35721
* gfortran.dg/associated_target_2.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/associated_target_2.f90
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/intrinsics/associated.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35721
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/35721] ASSOCIATED returns false when strides confusing
2008-03-27 16:49 [Bug fortran/35721] New: ASSOCIATED returns false when strides confusing dick dot hendrickson at gmail dot com
` (2 preceding siblings ...)
2008-03-28 13:48 ` burnus at gcc dot gnu dot org
@ 2008-03-28 13:50 ` burnus at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-03-28 13:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2008-03-28 13:49 -------
FIXED on the trunk (4.4.0). Thanks again for the report.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Keywords| |wrong-code
Resolution| |FIXED
Target Milestone|--- |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35721
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-03-28 13:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-27 16:49 [Bug fortran/35721] New: ASSOCIATED returns false when strides confusing dick dot hendrickson at gmail dot com
2008-03-27 18:28 ` [Bug fortran/35721] " burnus at gcc dot gnu dot org
2008-03-28 0:57 ` dick dot hendrickson at gmail dot com
2008-03-28 13:48 ` burnus at gcc dot gnu dot org
2008-03-28 13:50 ` burnus at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).