From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5404 invoked by alias); 19 Mar 2005 00:54:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 4901 invoked by uid 48); 19 Mar 2005 00:54:18 -0000 Date: Sat, 19 Mar 2005 00:54:00 -0000 Message-ID: <20050319005418.4899.qmail@sourceware.org> From: "tobi at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050318192834.20538.pinskia@gcc.gnu.org> References: <20050318192834.20538.pinskia@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug fortran/20538] compiling -finline-functions -O2 and we crash at runtime X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg02272.txt.bz2 List-Id: ------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-19 00:54 ------- Slightly reduced testcase, segfaults at -O2, runs with lower optimization. Removing any single statement leads to either illegal floating pointn numbers or makes the segfault disappear: character(len=8) argv real*8, parameter :: tstep = 0.01d0 real*8 :: e type body real*8 x, y,z,vx,vy,vz, mass end type body type(body), parameter :: jupiter = body(1d0, 1d0, 1d0, 1d0, 1d0, 1d0, 1d0 ) type(body), parameter :: sun = body(0.0d0, 0.0d0, 0.0d0, 0.0d0, 0.0d0, 0.0d0,1d0) type(body), dimension(2) :: bodies bodies = (/ sun, jupiter/) argv = "1" read (argv,*) num call offsetMomentum(1,bodies) do i=1,num call advance(tstep, bodies) end do e = 0. print *, e contains subroutine offsetMomentum(k, bodies) integer, intent(in) :: k type(body), dimension(:), intent(inout) :: bodies real*8 :: px, py, pz do i=1,size(bodies) px = bodies(i)%vx * bodies(i)%mass; end do bodies(k)%vx = -px end subroutine offsetMomentum subroutine advance(tstep, bodies) real*8, intent(in) :: tstep type(body), dimension(:), intent(inout) :: bodies real*8 dx, dy, dz, distance, mag integer i, j i = 1; j = 2; mag = 1. dx = bodies(i)%x - bodies(j)%x bodies(i)%vx = bodies(i)%vx - dx * bodies(j)%mass * mag bodies(j)%vx = bodies(j)%vx + dx * bodies(i)%mass * mag bodies(j)%vy = bodies(j)%vy + dy * bodies(i)%mass * mag bodies(j)%vz = bodies(j)%vz + dz * bodies(i)%mass * mag do i=1,size(bodies) bodies(i)%x = bodies(i)%x + tstep * bodies(i)%vx bodies(i)%y = bodies(i)%y + tstep * bodies(i)%vy bodies(i)%z = bodies(i)%z + tstep * bodies(i)%vz end do end subroutine advance real*8 function energy(bodies) type(body), dimension(:), intent(in) :: bodies real*8 dx, dy, dz, distance integer i, j energy = 0.0d0 end function energy end -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed| |1 Last reconfirmed|0000-00-00 00:00:00 |2005-03-19 00:54:17 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20538