From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 227D33851C3A; Fri, 13 Nov 2020 09:32:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 227D33851C3A From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug exp/26875] New: Incorrect value printed for address of first element of zero-length array Date: Fri, 13 Nov 2020 09:32:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: exp X-Bugzilla-Version: unknown 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: Fri, 13 Nov 2020 09:32:34 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26875 Bug ID: 26875 Summary: Incorrect value printed for address of first element of zero-length array Product: gdb Version: unknown Status: NEW Severity: normal Priority: P2 Component: exp Assignee: unassigned at sourceware dot org Reporter: vries at gcc dot gnu.org Target Milestone: --- Consider test-case gdb.base/arrayidx.exp, augmented with fedora patch https://src.fedoraproject.org/rpms/gdb/blob/master/f/gdb-archer-vla-tests.p= atch: ... diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c --- a/gdb/testsuite/gdb.base/arrayidx.c +++ b/gdb/testsuite/gdb.base/arrayidx.c @@ -17,6 +17,13 @@ int array[] =3D {1, 2, 3, 4}; +#ifdef __GNUC__ +struct + { + int a[0]; + } unbound; +#endif + int main (void) { diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp --- a/gdb/testsuite/gdb.base/arrayidx.exp +++ b/gdb/testsuite/gdb.base/arrayidx.exp @@ -49,4 +49,12 @@ gdb_test "print array" \ "\\{\\\[0\\\] =3D 1, \\\[1\\\] =3D 2, \\\[2\\\] =3D 3, \\\[3\\\] = =3D 4\\}" \ "print array with array-indexes on" - +set test "p unbound.a =3D=3D &unbound.a\[0\]" +gdb_test_multiple $test $test { + -re " =3D 1\r\n$gdb_prompt $" { + pass $test + } + -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" { + unsupported "$test (no GCC)" + } +} ... We run into this FAIL: ... p unbound.a =3D=3D &unbound.a[0]^M $7 =3D 0^M (gdb) FAIL: gdb.base/arrayidx.exp: p unbound.a =3D=3D &unbound.a[0] ... A bit more probing: ... (gdb) p unbound $3 =3D {a =3D 0x601044} (gdb) p &unbound $4 =3D (struct {...} *) 0x601044 (gdb) p unbound.a $5 =3D 0x601044 (gdb) p &unbound.a[0] $6 =3D (int *) 0xffffffffefc93d84^M ... reveals that we have a problem printing the address of the first element of= a zero length array. --=20 You are receiving this mail because: You are on the CC list for the bug.=