From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5703 invoked by alias); 19 Apr 2012 21:07:14 -0000 Received: (qmail 5690 invoked by uid 22791); 19 Apr 2012 21:07:13 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Apr 2012 21:06:54 +0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/53037] warn_if_not_aligned(X) Date: Thu, 19 Apr 2012 21:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-04/txt/msg01688.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53037 --- Comment #16 from H.J. Lu 2012-04-19 21:06:= 49 UTC --- Created attachment 27199 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=3D27199 A smaller patch There is no point to support struct foo { int i1; long long i2 __attribute__((aligned(4), warn_if_not_aligned(8))); }; since GCC won't decrease alignment in field. The smaller patch gave [hjl@gnu-6 pr53037]$ cat x.i typedef unsigned long long __u64 __attribute__((aligned(4),warn_if_not_aligned(8))); struct foo1 { int i1; int i2; int i3; __u64 x; }; struct foo2 { int i1; int i2; int i3; __u64 x; } __attribute__((aligned(8))); struct foo3 { int i1; int i2; __u64 x; } __attribute__((aligned(8))); struct foo4 { int i1; int i3; __u64 x; }; union bar1 { int i1; int i3; __u64 x; }; union bar2 { int i1; int i3; __u64 x; } __attribute__((aligned(8))); [hjl@gnu-6 pr53037]$ make x.s /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -mx32 -Wall -O2 -S x.i x.i:10:1: warning: alignment 4 of =E2=80=98struct foo1=E2=80=99 is less tha= n 8 [enabled by default] }; ^ x.i:9:9: warning: =E2=80=98x=E2=80=99 offset 12 in =E2=80=98struct foo1=E2= =80=99 isn't aligned to 8 [enabled by default] __u64 x; ^ x.i:17:9: warning: =E2=80=98x=E2=80=99 offset 12 in =E2=80=98struct foo2=E2= =80=99 isn't aligned to 8 [enabled by default] __u64 x; ^ x.i:32:1: warning: alignment 4 of =E2=80=98struct foo4=E2=80=99 is less tha= n 8 [enabled by default] }; ^ x.i:39:1: warning: alignment 4 of =E2=80=98union bar1=E2=80=99 is less than= 8 [enabled by default] }; ^ [hjl@gnu-6 pr53037]$