From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A2E9C385DDEB; Tue, 4 Jun 2024 21:51:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2E9C385DDEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1717537863; bh=ONVdf92T8uM8qI663Td+HQYAknVIm7EsCLuhev/BBJg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IZ+8cesVowLaAeWrlY0zJABlsSyGdZp3CdXAHA2ryyhavopVzd75DFi9j/5il7wP2 2U86juTGWq14ZQTkSW4s3iusgO1UQ7RaRhEvqy+p7F2yYA7RMgTbkWlSA3B/MROxbf Q6MbdFTkK7shspKHLgNyiry7uNSIvmd7/2eoPsPg= From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/59104] Wrong result with SIZE specification expression Date: Tue, 04 Jun 2024 21:51:02 +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: pault at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pault at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: assigned_to attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D59104 Paul Thomas changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gn= u.org --- Comment #6 from Paul Thomas --- Created attachment 58348 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D58348&action=3Dedit Fix for this PR This works and even regtests. I will include character lengths before submitting. The eventual testcase is rather more elaborate but the version below gives = an idea of what is now fixed, Paul module m1 implicit none integer, parameter :: dp =3D kind([double precision::]) contains function f(x) integer, intent(in) :: x real(dp) f(x/2) real(dp) g(x/2) ! block integer y(size(f)+1) integer z(size(f) + size(y)) ! This caused all manner of trouble. f =3D 10.0 y =3D 1 z =3D 1 write(*,*) 'size(f) =3D ', size(f), f write(*,*) 'size(y) =3D ', size(y), y write(*,*) 'size(z) =3D ', size(z), z ! end block end function f function e(x) result(f) integer, intent(in) :: x real(dp) f(x/2) real(dp) g(x/2) integer y(size(f)+1) integer z(size(f) + size(y)) ! As did this. f =3D 10.0 y =3D 1 z =3D 1 write(*,*) 'size(f) =3D ', size(f), f write(*,*) 'size(y) =3D ', size(y), y write(*,*) 'size(z) =3D ', size(z), z end function e end module m1 program bug3 use m1 implicit none real(dp) y y =3D sum(f(2)) print *, y y =3D sum(e(4)) print *, y end program bug3=