From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18867 invoked by alias); 3 Jun 2009 21:22:44 -0000 Received: (qmail 18827 invoked by uid 48); 3 Jun 2009 21:22:33 -0000 Date: Wed, 03 Jun 2009 21:22:00 -0000 Subject: [Bug c++/40333] New: g++ does not align static variables properly X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "gccsse at mailinator 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: 2009-06/txt/msg00164.txt.bz2 The following SSE2 code crashes because the non-static global variable breaks the alignment of the static data section. align.cpp: #include int nonstatic_padding; static int static_padding[3]; static __attribute__((aligned(16))) __m128i sse_data; int main() { static_padding[0] = 1234; sse_data = _mm_set1_epi32(123); return 0; } The example uses SSE2 because that's how I discovered the bug and because it results in a nice crash, though I don't think it's essential at all. Results: - crashes (even when static_padding is removed) - no longer crashes when removing nonstatic_padding (even when static_padding is present) - no longer crashes when making sse_data non-static Tested with: g++-4 (GCC) 4.3.2 20080827 (beta) 2 and g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) (I know they're a bit old, but Cygwin doesn't provide more recent binaries) If you rename the file to align.c gcc compiles it correctly and the program does not crash (gcc places static variables before non-static ones, unlike g++). -- Summary: g++ does not align static variables properly Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gccsse at mailinator dot com GCC build triplet: i686-pc-cygwin GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40333