[Bug d/117002] [13/14/15 Regression] lifetime.d: In function ‘_d_newclassT’: error: size of array element is not a multiple of its alignment with -Warray-bounds and -O2
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 31 17:20:33 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117002
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Iain Buclaw
<ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:bfc9520eab16379aa47121d336bfd4d38c6d040a
commit r13-9480-gbfc9520eab16379aa47121d336bfd4d38c6d040a
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Sat Mar 29 23:16:25 2025 +0100
d: Fix error with -Warray-bounds and -O2 [PR117002]
The record layout of class types in D don't get any tail padding, so it
is possible for the `classInstanceSize' to not be a multiple of the
`classInstanceAlignment'.
Rather than setting the instance alignment on the underlying
RECORD_TYPE, instead give the type an alignment of 1, which will mark it
as TYPE_PACKED. The value of `classInstanceAlignment' is instead
applied to the DECL_ALIGN of both the static `init' symbol, and the
stack allocated variable used when generating `new' for a `scope' class.
PR d/117002
gcc/d/ChangeLog:
* decl.cc (aggregate_initializer_decl): Set explicit decl alignment
of
class instance.
* expr.cc (ExprVisitor::visit (NewExp *)): Likewise.
* types.cc (TypeVisitor::visit (TypeClass *)): Mark the record type
of
classes as packed.
gcc/testsuite/ChangeLog:
* gdc.dg/torture/pr117002.d: New test.
(cherry picked from commit 9fadadbbbc2b5352e5e70e0e1a9be9b447176913)
More information about the Gcc-bugs
mailing list