From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77819 invoked by alias); 18 Aug 2015 08:15:39 -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 Received: (qmail 77746 invoked by uid 48); 18 Aug 2015 08:15:35 -0000 From: "fxcoudert at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59104] Wrong result with SIZE specification expression Date: Tue, 18 Aug 2015 08:15: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-Version: 4.9.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: fxcoudert at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on cc blocked Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg01187.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59104 Francois-Xavier Coudert changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2013-12-19 00:00:00 |2015-8-18 CC| |fxcoudert at gcc dot gnu.org Blocks| |32834 --- Comment #2 from Francois-Xavier Coudert --- F95 bug. Still present. In the generated code, the size of Y is computed before the bounds for the F result are set, which leads to the error. Slightly reduced testcase: $ cat a.f90 program bug3 real y(2) y = f(2) print *, y contains function f(x) integer x real f(x) integer y(size(f)) write(*,*) 'size(f) = ',size(f) write(*,*) 'size(y) = ',size(y) f = -42 end function f end program bug3 $ gfortran a.f90 -std=f95 && ./a.out size(f) = 2 size(y) = 0 -42.0000000 -42.0000000 Slight modification of the source leads to an ICE on what I think is invalid code: $ cat a.f90 function f(x) integer x integer y(size(f)) real f(x) write(*,*) 'size(f) = ',size(f) write(*,*) 'size(y) = ',size(y) f = -42 end function f $ gfortran a.f90 -std=f95 && ./a.out a.f90:3:0: integer y(size(f)) 1 internal compiler error: in gfc_conv_expr_descriptor, at fortran/trans-array.c:6534 Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=32834 [Bug 32834] [Meta-bug] 'Fortran 95'-only failures