From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <sourceware-bugzilla@sourceware.org>
Received: by sourceware.org (Postfix, from userid 48)
	id CDABB385843A; Sat, 29 Apr 2023 11:19:54 +0000 (GMT)
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDABB385843A
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org;
	s=default; t=1682767194;
	bh=Tq0MiDYbZAQehhMsbyHoMTiahwzOsb9lOUe6R6M/C5w=;
	h=From:To:Subject:Date:From;
	b=XpYE70EfEGwhDBRNexkzFeTmAEN+MgyeboIvL6MAbba9JagvTNlh+IZDQayu1wK+l
	 pde8wOSRPpx9eIjS8jcGuYRyz2B1iQn99hk5YRGQT8lOsUGGOUQk3ua+O2z4YPZjzA
	 0oYnP40nzupaQeIuReqRrSjaLxuV7dq7fQ6h0aYM=
From: "mockbutler at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug exp/30404] New: Incorrect evaluation of sizeof(*pointer) for
 structure with zero length array
Date: Sat, 29 Apr 2023 11:19:54 +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: 12.1
X-Bugzilla-Keywords: 
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mockbutler at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
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
 attachments.created
Message-ID: <bug-30404-4717@http.sourceware.org/bugzilla/>
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
List-Id: <gdb-prs.sourceware.org>

https://sourceware.org/bugzilla/show_bug.cgi?id=3D30404

            Bug ID: 30404
           Summary: Incorrect evaluation of sizeof(*pointer) for structure
                    with zero length array
           Product: gdb
           Version: 12.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: exp
          Assignee: unassigned at sourceware dot org
          Reporter: mockbutler at gmail dot com
  Target Milestone: ---

Created attachment 14856
  --> https://sourceware.org/bugzilla/attachment.cgi?id=3D14856&action=3Ded=
it
Use with gdb to demonstrate bug.

When the last element of a C language struct is a zero length array, the
evaluation of sizeof(*(struct S*)pointer) does not match sizeof(struct S).

> Breakpoint 1, fn (ps=3D0x7fffffffe250) at demo-sizeof-bug.c:15
> 15              printf("ps =3D %p\n", ps);
> (gdb) p sizeof(*ps)
> $1 =3D 7
> (gdb) p sizeof(struct S)
> $2 =3D 8
> (gdb) ptype/o *ps
> /* offset      |    size */  type =3D struct S {
> /*      0      |       4 */    int32_t f1;
> /*      4      |       2 */    int16_t f2;
> /*      6      |       1 */    int8_t f3;
> /*      7      |       0 */    int8_t f4[];
>                              /* total size (bytes):    7 */

--=20
You are receiving this mail because:
You are on the CC list for the bug.=