From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4F1E83857821; Wed, 15 Sep 2021 23:05:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F1E83857821 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102295] ELF symbol sizes for variable-length objects are too small (C++) Date: Wed, 15 Sep 2021 23:05:17 +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: 12.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Sep 2021 23:05:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102295 --- Comment #8 from CVS Commits --- The releases/gcc-11 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:6550198bd8467f435959fa25b69c217a6ef75c7a commit r11-8998-g6550198bd8467f435959fa25b69c217a6ef75c7a Author: Jakub Jelinek Date: Tue Sep 14 16:56:30 2021 +0200 c++: Update DECL_*SIZE for objects with flexible array members with initializers [PR102295] The C FE updates DECL_*SIZE for vars which have initializers for flexib= le array members for many years, but C++ FE kept DECL_*SIZE the same as the type size (i.e. as if there were zero elements in the flexible array member). This results e.g. in ELF symbol sizes being too small. Note, if the flexible array member is initialized only with non-constant initializers, we have a worse bug that this patch doesn't solve, the splitting of initializers into constant and dynamic initialization remo= ves the initializer and we don't have just wrong DECL_*SIZE, but nothing is emitted when emitting those vars into assembly either and so the dynamic initialization clobbers other vars that may overlap the variable. I think we need keep an empty CONSTRUCTOR elt in DECL_INITIAL for the flexible array member in that case. 2021-09-14 Jakub Jelinek PR c++/102295 * decl.c (layout_var_decl): For aggregates ending with a flexib= le array member, add the size of the initializer for that member to DECL_SIZE and DECL_SIZE_UNIT. * g++.target/i386/pr102295.C: New test. (cherry picked from commit 818c505188ff5cd8eb048eb0e614c4ef732225bd)=