From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20556 invoked by alias); 3 Sep 2013 09:23:01 -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 Received: (qmail 20518 invoked by uid 48); 3 Sep 2013 09:22:58 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58270] Wrong code while accessing trailing array elements in a global common structure Date: Tue, 03 Sep 2013 09:23:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 4.6.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: critical X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_gcctarget bug_status cc component cf_gcchost short_desc cf_known_to_fail Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-09/txt/msg00115.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58270 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Target|i386-pc-linux | Status|WAITING |NEW CC| |rguenth at gcc dot gnu.org Component|fortran |middle-end Host|i386-pc-linux | Summary|Wrong code while accessing |Wrong code while accessing |array elements in a global |trailing array elements in |structure |a global common structure Known to fail| |4.9.0 --- Comment #19 from Richard Biener --- DECL_COMMONs could be special-cased in places that look at DECL_SIZE (I'll declare this a QOI issue). Or all decls that do not bind locally. The place that would "fix" tree-fre, tree-pre and tree-dse is in get_ref_base_and_extent where it does if (DECL_P (exp)) { /* If maxsize is unknown adjust it according to the size of the base decl. */ if (maxsize == -1 && host_integerp (DECL_SIZE (exp), 1)) maxsize = TREE_INT_CST_LOW (DECL_SIZE (exp)) - hbit_offset; } else if (CONSTANT_CLASS_P (exp)) { /* If maxsize is unknown adjust it according to the size of the base type constant. */ if (maxsize == -1 && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)) maxsize = TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))) - hbit_offset; } In its general processing the function treats all trailing arrays as possibly of undefined size. Note that because -fcommon is still the default for all C dialects the impact of changing the above for example in the simple && !DECL_COMMON (exp) way is unknown. -fcommon is a source of interesting bugs.