From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2259 invoked by alias); 26 Sep 2009 04:04:27 -0000 Received: (qmail 876 invoked by uid 48); 26 Sep 2009 04:04:09 -0000 Date: Sat, 26 Sep 2009 04:04:00 -0000 Subject: [Bug middle-end/41475] New: common variables cannot be expected to be aligned X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mikulas at artax dot karlin dot mff dot cuni dot cz" 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-09/txt/msg02388.txt.bz2 Hi. When I compile these two sources, one with -O3 -march=pentium3 and the other with -Os, the linker warns about nonmatching alignments and the program crashes because of misaligned SSE accesses. /usr/bin/ld: Warning: alignment 4 of symbol `array' in commonalign2.o is smaller than 32 in commonalign1.o /usr/bin/ld: Warning: alignment 4 of symbol `array2' in commonalign2.o is smaller than 32 in commonalign1.o The reson is that gcc aligns arrays in common section to 32 bytes and expects that they will be aligned so. This expectation is wrong, the common entries may be resolved pointing to data section in another module that doesn't meet the alignment (it may be compiled with different compiler or with the same compiler with different flags (-Os)). For extern arrays, gcc correctly assumes that they are aligned to their ABI standard (4 bytes) and generates appropriate SSE code; for common arrays it should expect 4-byte alignment too. -- Summary: common variables cannot be expected to be aligned Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: mikulas at artax dot karlin dot mff dot cuni dot cz GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41475