From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D5BDC3851C3D; Thu, 12 Nov 2020 12:50:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5BDC3851C3D From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug fortran/26870] New: [fortran] Printing dynamic array fails Date: Thu, 12 Nov 2020 12:50:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: fortran X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot 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://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2020 12:50:52 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26870 Bug ID: 26870 Summary: [fortran] Printing dynamic array fails Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: fortran Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider test-case gdb.fortran/dynamic.exp, as added in fedora patch https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer-vla-tests.p= atch . When building current trunk gdb with CFLAGS/CXXFLAGS as in the openSUSE Leap 15.2 gdb package: ... CFLAGS=3D"-fmessage-length=3D0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_S= OURCE=3D2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -g" CXXFLAGS=3D"$CFLAGS -Wno-error=3Dodr" ... we run into: ... (gdb) PASS: gdb.fortran/dynamic.exp: ptype vart p varz^M $26 =3D (warning: array or string index out of range^M ^M (gdb) FAIL: gdb.fortran/dynamic.exp: p varz ... This can be reproduced on the command line: ... $ gdb -batch dynamic \ -ex "b 68" \ -ex r \ -ex "p varz"=20 Breakpoint 1 at 0x400aac: file dynamic.f90, line 68. Breakpoint 1, bar (varz=3D..., vart=3D...) at dynamic.f90:68 68 varz(2) =3D 5 ! varz-almostfill= ed^M $1 =3D (warning: array or string index out of range ... The problem is here, in f77_print_array_1. Before calling get_discrete_bou= nds, upperbound is uninitialized, and randomly set to a large value: ... 120 get_discrete_bounds (range_type, &lowerbound, &upperbound); (gdb) p lowerbound $1 =3D 0 (gdb) p upperbound $2 =3D 31290496 ... Stepping into get_discrete_bounds, we can see that it returns -1: ... (gdb) s get_discrete_bounds () at gdbtypes.c:1045 1045 { (gdb) fin Run till exit from #0 get_discrete_bounds () at gdbtypes.c:1045 f77_print_array_1 () at f-valprint.c:122 122 if (nss !=3D ndimensions) Value returned is $3 =3D -1 ... and the bounds are unchanged: ... (gdb) p lowerbound $4 =3D 0 (gdb) p upperbound $5 =3D 31290496 ... which causes the warning and error. And get_discrete_bounds returns -1 because: ... (gdb) p type.main_type.flds_bnds.bounds.low $18 =3D {m_kind =3D PROP_CONST, m_data =3D {const_val =3D 1, baton =3D 0x1,= variant_parts =3D 0x1,=20 original_type =3D 0x1}} (gdb) p type.main_type.flds_bnds.bounds.high $19 =3D {m_kind =3D PROP_UNDEFINED, m_data =3D {const_val =3D 6003792,=20 baton =3D 0x5b9c50 ,=20 variant_parts =3D 0x5b9c50 ,=20 original_type =3D 0x5b9c50 }} ... --=20 You are receiving this mail because: You are on the CC list for the bug.=