From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2A7073858D1E; Sun, 9 Apr 2023 00:02:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A7073858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680998560; bh=/rYvOrnnkfIRiBxa0r7tbTJRsFASyq0D7ROzcGRjQKU=; h=From:To:Subject:Date:From; b=bi1fHjYXbg8LEM72AaQ0m3pVib2SV3Qll0KJ0JZ1Oa+fXLjGSWQGFKb9EF/RsjxOk gxYCmNuGBjCzIDIjwlMhV0wkW5sNOWoOENFK17Gct9VxgluiX3quMG/ZWc+HBjzMDy XoMogzyw/NAmJbxo2ps+q8CCZfIsXhnQA8hLE4eU= From: "jvdelisle at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/109453] New: UBOUND incorrect when used in declartion of another array Date: Sun, 09 Apr 2023 00:02:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jvdelisle at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D109453 Bug ID: 109453 Summary: UBOUND incorrect when used in declartion of another array Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jvdelisle at gcc dot gnu.org Target Milestone: --- The following program illustrates: integer, parameter :: a(0:19)=3D(/(i,i=3D0,19)/) integer :: b(-1:ubound(a,dim=3D1)) ! <<<< This gives wrong result ! integer, parameter :: c =3D ubound(a,dim=3D1) ! Using an intermediate wo= rks ! integer :: b(-1:c) ! Using the intermediate b(-1:ubound(a,dim=3D1))=3D(/0,a(0:19)/) write(*,'(1000i3)') a write(*,'(1000i3)') b print *, rank(b), size(b), ubound(b), lbound(b) print *, rank(a), size(a), ubound(a), lbound(a) end Giving: $ ./a.out=20 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 1 22 20 -1 1 20 19 0 Commenting out the wrong result line and uncommenting the alternate lines: $ ./a.out=20 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 21 19 -1 1 20 19 0 Looks like an off by one somewhere.=