From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26416 invoked by alias); 22 Jan 2008 14:26:55 -0000 Received: (qmail 25745 invoked by uid 48); 22 Jan 2008 14:26:12 -0000 Date: Tue, 22 Jan 2008 14:47:00 -0000 Message-ID: <20080122142612.25740.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/34921] Misalign stack variable referenced by nested function In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "hjl dot tools at gmail dot com" 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: 2008-01/txt/msg02563.txt.bz2 ------- Comment #4 from hjl dot tools at gmail dot com 2008-01-22 14:26 ------- (In reply to comment #2) > I bet if you put jj in struct and don't have a nested function, this will be > the same issue. > struct works for me: bash-3.2$ cat x.c #include #include #include #ifndef ALIGNMENT #define ALIGNMENT 16 #endif int check_int (int *i, int align) { *i = 20; if ((((ptrdiff_t) i) & (align - 1)) != 0) { printf("\nUnalign address (%d): %p!\n", align, i); abort (); } return *i; } void foo (void) { struct i { int i; } __attribute__((aligned(ALIGNMENT))) i; if (check_int (&i.i, __alignof__(i.i)) != i.i) abort (); } void bar (void) { int __attribute__((aligned(ALIGNMENT))) i; if (check_int (&i, __alignof__(i)) != i) abort (); } int main() { foo (); bar (); return 0; } bash-3.2$ /usr/gcc-4.3/bin/gcc -m32 x.c bash-3.2$ ./a.out bash-3.2$ -- hjl dot tools at gmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2008-01-22 14:26:12 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34921