This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/27945] [4.0/4.1/4.2/4.3 Regression] Packed struct of variable length has wrong size
- From: "jason at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Nov 2006 01:10:19 -0000
- Subject: [Bug middle-end/27945] [4.0/4.1/4.2/4.3 Regression] Packed struct of variable length has wrong size
- References: <bug-27945-12799@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from jason at gcc dot gnu dot org 2006-11-14 01:10 -------
Ah, I see the problem. The code I removed from the C and C++ front ends was
redundant with code in layout_decl, except that the code in layout_decl
deliberately ignores DECL_PACKED for fields of variable size.
/* If the field is of variable size, we can't misalign it since we
have no way to make a temporary to align the result. But this
isn't an issue if the decl is not addressable. Likewise if it
is of unknown size.
Note that do_type_align may set DECL_USER_ALIGN, so we need to
check old_user_align instead. */
=> if (packed_p
&& !old_user_align
&& (DECL_NONADDRESSABLE_P (decl)
|| DECL_SIZE_UNIT (decl) == 0
|| TREE_CODE (DECL_SIZE_UNIT (decl)) == INTEGER_CST))
DECL_ALIGN (decl) = MIN (DECL_ALIGN (decl), BITS_PER_UNIT);
This dates back to a change of Kenner's from 2001:
Sat Dec 29 15:48:54 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* stor-layout.c (layout_decl): Don't misalign field of variable size
for packed record.
Richard, do you have any input? Do you think there a way to make that test
more specific to the case were fixing?
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kenner at vlsi1 dot ultra
| |dot nyu dot edu
AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2006-06-09 07:45:54 |2006-11-14 01:10:19
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27945