From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15919 invoked by alias); 21 Nov 2009 16:26:42 -0000 Received: (qmail 15878 invoked by uid 48); 21 Nov 2009 16:26:31 -0000 Date: Sat, 21 Nov 2009 16:26:00 -0000 Message-ID: <20091121162631.15877.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug fortran/42131] Weird translation of DO loops In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "kargl at gcc dot gnu dot org" 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: 2009-11/txt/msg01797.txt.bz2 ------- Comment #1 from kargl at gcc dot gnu dot org 2009-11-21 16:26 ------- (In reply to comment #0) > To illustrate this with a simple example: > > DO I = M1, M2, M3 > B(I) = A(I) > ENDDO > > would be most easily, and atraightforwardly, implemented as follows: > > IF (M3 > 0 .AND. M1 < M2) GOTO 200 ! Loop executed zero times > IF (M3 < 0 .AND. M1 > M2) GOTO 200 ! Ditto First, I just woke up 10 minutes ago and still have 1/2 of cup of coffee, but the logic above looks wrong. do i = 1, 2, 1 print *, i end do should produce 1 2 Here, we have m1 = 1, m2 = 2, m3 = 1 > IF (M3 > 0 .AND. M1 < M2) GOTO 200 ! Loop executed zero times -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42131