From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31822 invoked by alias); 25 Jun 2015 01:26:23 -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 31797 invoked by uid 48); 25 Jun 2015 01:26:20 -0000 From: "P at draigBrady dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66661] incorrect memory access in optimization with flexible array member Date: Thu, 25 Jun 2015 01:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: P at draigBrady dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02489.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66661 --- Comment #1 from P=C3=A1draig Brady

--- Created attachment 35849 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D35849&action=3Dedit summary code (does not reproduce issue) >>From gcc-bugs-return-490159-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 01:27:48 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 34313 invoked by alias); 25 Jun 2015 01:27:48 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 34291 invoked by uid 48); 25 Jun 2015 01:27:44 -0000 From: "P at draigBrady dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/66661] incorrect memory access in optimization with flexible array member Date: Thu, 25 Jun 2015 01:27: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: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: P at draigBrady dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02491.txt.bz2 Content-length: 261 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66661 --- Comment #3 from P=C3=A1draig Brady

--- Created attachment 35851 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D35851&action=3Dedit disassembly of forced good mem access >>From gcc-bugs-return-490158-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 01:27:13 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 33463 invoked by alias); 25 Jun 2015 01:27:13 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 33425 invoked by uid 48); 25 Jun 2015 01:27:10 -0000 From: "P at draigBrady dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/66661] incorrect memory access in optimization with flexible array member Date: Thu, 25 Jun 2015 01:27: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: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: P at draigBrady dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: attachments.created Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02490.txt.bz2 Content-length: 261 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66661 --- Comment #2 from P=C3=A1draig Brady

--- Created attachment 35850 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D35850&action=3Dedit disassembly of problematic mem access >>From gcc-bugs-return-490160-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 01:39:44 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 43921 invoked by alias); 25 Jun 2015 01:39:44 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 43882 invoked by uid 48); 25 Jun 2015 01:39:40 -0000 From: "P at draigBrady dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/66661] incorrect memory access in optimization with flexible array member Date: Thu, 25 Jun 2015 01:39: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: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: P at draigBrady dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02492.txt.bz2 Content-length: 356 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66661 --- Comment #4 from P=C3=A1draig Brady

--- I should note that I worked around the issue by increasing the allocation f= or the structure on the heap up to a multiple of alignof(the_struct). See: http://git.savannah.gnu.org/gitweb/?p=3Dgnulib.git;a=3Dcommitdiff;h=3D49078= a78 >>From gcc-bugs-return-490161-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 01:46:10 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 98087 invoked by alias); 25 Jun 2015 01:46:10 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 95231 invoked by uid 48); 25 Jun 2015 01:46:05 -0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/66661] incorrect memory access in optimization with flexible array member Date: Thu, 25 Jun 2015 01:46: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: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: bug_status resolution Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-06/txt/msg02493.txt.bz2 Content-length: 968 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66661 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #5 from Andrew Pinski --- (In reply to P=C3=A1draig Brady from comment #4) > I should note that I worked around the issue by increasing the allocation > for the structure on the heap up to a multiple of alignof(the_struct). Se= e: > http://git.savannah.gnu.org/gitweb/?p=3Dgnulib.git;a=3Dcommitdiff;h=3D490= 78a78 That is not just a workaround but a correct patch. The size of the memory allocated needs to be a multiply of the alignment of the struct to be valid. The reason why it works for you with your reduced testcase is because the alignment of the struct is 1. >>From gcc-bugs-return-490162-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 01:51:12 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 38596 invoked by alias); 25 Jun 2015 01:51:12 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 37607 invoked by uid 48); 25 Jun 2015 01:51:07 -0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/66661] incorrect memory access in optimization with flexible array member Date: Thu, 25 Jun 2015 01:51: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: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_status resolution 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: 2015-06/txt/msg02494.txt.bz2 Content-length: 613 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID |--- --- Comment #6 from Andrew Pinski --- More to the point this might actually be a -fsanitize=address bug so reopening for that issue. By the way we know the alignment of the struct is 4 which means loading a 4 byte would be valid.