From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 787A53857710; Thu, 25 May 2023 07:53:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 787A53857710 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685001216; bh=Dub11OMqZUnStD9qXPKi46sFjzfOPxXfRa3ytasi3L4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rysrN6bBKkyaroJLeJFyhO9erBHwo8u+7Oto13V//vNUb2nqeJeLErLPSpLdgxrHk oZ47MsQEz7IClLhzVv4ZEI5vr4NxoVQ2ilVRS6vje2nd1bHgk19wnDdTQcgnhQMDQV vDpoYdNVqNOjTh3KTsgL7BmJWwwhyPVpqo5dEjqc= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/109956] GCC reserves 9 bytes for struct s { int a; char b; char t[]; } x = {1, 2, 3}; Date: Thu, 25 May 2023 07:53:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: trivial X-Bugzilla-Who: rguenth 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: 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=3D109956 --- Comment #11 from Richard Biener --- (In reply to Alexander Monakov from comment #8) > (In reply to joseph@codesourcery.com from comment #6) > > For the standard, dynamically allocated case, you should only need to=20 > > allocate enough memory to contain the initial part of the struct and th= e=20 > > array members being accessed - not any padding after that array. (Ther= e=20 > > were wording problems before C99 TC2; see DR#282.) >=20 > I think the following testcase indicates that GCC assumes that tail paddi= ng > is accessible: >=20 > struct S { > int i; > char c; > char fam[]; > }; >=20 > void f(struct S *p, struct S *q) > { > *p =3D *q; > } >=20 > f: > movq (%rsi), %rax > movq %rax, (%rdi) > ret >=20 > Sorry for the tangential remark, but there seems to be a contradiction. Not only accessible but also not used by sth else. That is, a following 'char' variable may not be placed into the padding.=