From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15433 invoked by alias); 15 Mar 2011 18:00:39 -0000 Received: (qmail 15413 invoked by uid 22791); 15 Mar 2011 18:00:36 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Tue, 15 Mar 2011 18:00:32 +0000 From: "d.g.gorbachev at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/48127] Program crashes reading a non-aligned variable X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: ssemmx, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: d.g.gorbachev 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" MIME-Version: 1.0 Date: Tue, 15 Mar 2011 18:09:00 -0000 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: 2011-03/txt/msg01596.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48127 --- Comment #3 from Dmitry Gorbachev 2011-03-15 18:00:23 UTC --- I do not agree that the testcase is invalid. As the standart says: Common extensions Multiple external definitions There may be more than one external definition for the identifier of an object, with or without the explicit use of the keyword extern; if the definitions disagree, or more than one is initialized, the behavior is undefined. According to the Binutils documentation, The linker turns a common symbol into a declaration, if there is a definition of the same variable. Also, from Ian Lance Taylor's article [1]: 5. If A is a strong definition in an object file: * If B is a common symbol, then we treat B as an undefined reference. I think it would be better to fix this problem in the linker. Gold does not even warn about it! However, I don't understand why GCC makes baz[8] to have 32 bytes alignment, while baz[4] has only 4 bytes alignment. It seems to be a GCC bug. When baz is declared extern in main.c, the generated code is correct, but less optimal. 1. http://www.airs.com/blog/archives/49