From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3511 invoked by alias); 21 May 2011 23:23:34 -0000 Received: (qmail 3502 invoked by uid 22791); 21 May 2011 23:23:34 -0000 X-SWARE-Spam-Status: No, hits=-2.7 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; Sat, 21 May 2011 23:23:20 +0000 From: "dominiq at lps dot ens.fr" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49103] [4.6/4.7 Regression] local variables exchange values / wrong code with -O3 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal 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 Date: Sat, 21 May 2011 23:29:00 -0000 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-05/txt/msg01892.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49103 --- Comment #4 from Dominique d'Humieres 2011-05-21 23:11:01 UTC --- Reverting revision 169083 on trunk fixes this pr (see http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01442.html for its motivation). Further reduced test: !---------------------------------- module dg_grid implicit none integer :: par_world_dims = 3 type world_t integer :: dims real(kind=8), dimension(:), pointer :: lengths end type contains subroutine grid_new(grid) type(world_t), intent(inout) :: grid grid%dims = par_world_dims call grid_faces(grid) end subroutine ! Start looking here: This is the routine that gives trouble. subroutine grid_faces(grid) type(world_t), intent(inout) :: grid integer :: dimi, bordi integer, dimension(par_world_dims-1) :: fgrades integer, dimension(par_world_dims-1) :: fbasegrades do dimi=1,grid%dims-2 ! The bug makes those two arrays exchange values temporarily. fbasegrades = (/ 1, 1 /) fgrades = (/ 2, 2 /) do bordi=1,2 write(*,*) 'Here is the bug. The grades should be (2 2):', fgrades write(*,*) 'Compare the base grades:', fbasegrades end do write(*,*) 'grades again', fgrades end do end subroutine end module program test_gcc46gridbug use dg_grid implicit none type(world_t) :: grid call grid_new(grid) end program !----------------------------------