This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/53037] warn_if_not_aligned(X)
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 18 Aug 2017 20:52:12 +0000
- Subject: [Bug c/53037] warn_if_not_aligned(X)
- Auto-submitted: auto-generated
- References: <bug-53037-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53037
--- Comment #29 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to ro@CeBiTec.Uni-Bielefeld.DE from comment #28)
> > --- Comment #27 from H.J. Lu <hjl.tools at gmail dot com> ---
>
> > What are error messages?
>
> None, the warnings are simply missing.
>
> Rainer
Sparc defines STRICT_ALIGNMENT which leads to
unsigned mode_align = GET_MODE_ALIGNMENT (TYPE_MODE (type));
/* Don't override a larger alignment requirement coming from a user
alignment of one of the fields. */
if (mode_align >= TYPE_ALIGN (type))
{
SET_TYPE_ALIGN (type, mode_align);
TYPE_USER_ALIGN (type) = 0;
}
so __attribute__ ((packed)) is basically ignored on Sparc. This patch
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 3028d55773a..6dd605810ac 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1784,7 +1784,7 @@ finalize_type_size (tree type)
/* Don't override a larger alignment requirement coming from a user
alignment of one of the fields. */
- if (mode_align >= TYPE_ALIGN (type))
+ if (mode_align > TYPE_ALIGN (type))
{
SET_TYPE_ALIGN (type, mode_align);
TYPE_USER_ALIGN (type) = 0;
works with cross compiler. But I have no idea if it is correct.