[Bug c++/102295] ELF symbol sizes for variable-length objects are too small (C++)
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue May 10 08:20:44 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102295
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:e54c8a86166fff6357729a3cde1b1cd143985abe
commit r10-10643-ge54c8a86166fff6357729a3cde1b1cd143985abe
Author: Jakub Jelinek <jakub@redhat.com>
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 flexible
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 removes
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 <jakub@redhat.com>
PR c++/102295
* decl.c (layout_var_decl): For aggregates ending with a flexible
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)
More information about the Gcc-bugs
mailing list