From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16595 invoked by alias); 5 Oct 2011 21:40:38 -0000 Received: (qmail 16582 invoked by uid 22791); 5 Oct 2011 21:40:35 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 05 Oct 2011 21:40:22 +0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/47844] Array stride ignored for pointer-valued function results Date: Wed, 05 Oct 2011 21:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: minor X-Bugzilla-Who: dominiq at lps dot ens.fr X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00285.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47844 --- Comment #8 from Dominique d'Humieres 2011-10-05 21:39:31 UTC --- > We could fix this in 4.7 by adding a sm field to array descriptors. I don't see why. I have looked at the dump.original of the following code: integer, target :: tgt(9) = [1,2,3,4,5,6,7,8,9] integer, pointer :: p(:) integer :: var(3) p => tgt(ubound(tgt,1)-4:lbound(tgt,1):-2) var = p print *, var ! prints 5 3 1 var = f(tgt) ! should assign 5 3 1 print *, var ! but prints 5 6 7 if(any(var/=[5,3,1])) call abort() contains function f(x) result(r) integer, target :: x(:) integer, pointer :: r(:) r => x(ubound(x,1)-4:lbound(x,1):-2) print *, r ! prints 5 3 1 end function f end The first assignment (var = p) is p.dtype = 265; p.dim[0].lbound = 1; p.dim[0].ubound = 3; p.dim[0].stride = -2; p.data = (void *) &tgt[4]; p.offset = 2; { integer(kind=8) D.1793; integer(kind=8) D.1792; integer(kind=8) D.1791; integer(kind=8) D.1790; integer(kind=4)[0:] * D.1789; D.1789 = (integer(kind=4)[0:] *) p.data; D.1790 = p.offset; D.1791 = p.dim[0].lbound; D.1792 = p.dim[0].ubound; D.1793 = D.1791 + -1; { integer(kind=8) D.1795; integer(kind=8) S.7; D.1795 = p.dim[0].stride; S.7 = 1; while (1) { if (S.7 > 3) goto L.1; var[S.7 + -1] = (*D.1789)[(S.7 + D.1793) * D.1795 + D.1790]; S.7 = S.7 + 1; } L.1:; } } while the second one (var = f(tgt)) is: f (&atmp.12, D.1804); { integer(kind=8) S.13; S.13 = 0; while (1) { if (S.13 > 2) goto L.2; var[S.13] = (*(integer(kind=4)[3] * restrict) atmp.12.data)[S.13]; S.13 = S.13 + 1; } L.2:; } As far I understand the dump, atmp.12 is set with the same values as p (through an awfully complicated process), but atmp.12.dim[0].stride is not used in the assignment.