public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66661] New: incorrect memory access in optimization with flexible array member
@ 2015-06-25  1:25 P at draigBrady dot com
  2015-06-25  1:26 ` [Bug c/66661] " P at draigBrady dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: P at draigBrady dot com @ 2015-06-25  1:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661

            Bug ID: 66661
           Summary: incorrect memory access in optimization with flexible
                    array member
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: P at draigBrady dot com
  Target Milestone: ---

On a heap allocated structure, direct access to flexible array members with
optimization at -O2 can result in reads to memory beyond the heap object.
I.E. gcc assumes alignment/padding is allocated when accessing flexible array
members. The attached file is a summary of the code involved though does _not_
reproduce the issue.

To reproduce one can:

  git clone --depth=1 git://git.sv.gnu.org/coreutils.git
  cd coreutils/
  git checkout 53883af0
  export LSAN_OPTIONS=exitcode=0
  ./bootstrap && ./configure --quiet && \
  make -j8 AM_CFLAGS='-fsanitize=address -fsanitize=undefined'
  src/chmod a+rx ..

Also attached is the disassembly of the problematic code,
and for comparison good code achieved by using a (char*) cast
on the flexi array to force byte at a time access.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/66661] incorrect memory access in optimization with flexible array member
  2015-06-25  1:25 [Bug c/66661] New: incorrect memory access in optimization with flexible array member P at draigBrady dot com
@ 2015-06-25  1:26 ` P at draigBrady dot com
  2015-06-25  2:01 ` [Bug middle-end/66661] " P at draigBrady dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: P at draigBrady dot com @ 2015-06-25  1:26 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 11933 bytes --]

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661

--- Comment #1 from Pádraig Brady <P at draigBrady dot com> ---
Created attachment 35849
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35849&action=edit
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: <gcc-bugs-return-490159-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: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: <bug-66661-4-dLVNdEItL0@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
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=66661

--- Comment #3 from Pádraig Brady <P at draigBrady dot com> ---
Created attachment 35851
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35851&action=edit
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: <gcc-bugs-return-490158-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: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: <bug-66661-4-CWtlelqm8W@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
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=66661

--- Comment #2 from Pádraig Brady <P at draigBrady dot com> ---
Created attachment 35850
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35850&action=edit
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: <gcc-bugs-return-490160-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: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: <bug-66661-4-FeAcP7UU6l@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
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=66661

--- Comment #4 from Pádraig Brady <P at draigBrady dot com> ---
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). See:
http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=49078a78
>From gcc-bugs-return-490161-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 01:46:10 2015
Return-Path: <gcc-bugs-return-490161-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: <bug-66661-4-BF2GRwnzyk@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
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=66661

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Pádraig 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). See:
> http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=49078a78

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: <gcc-bugs-return-490162-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
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: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
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" <gcc-bugzilla@gcc.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: <bug-66661-4-sd24h7x1hj@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66661-4@http.gcc.gnu.org/bugzilla/>
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?idf661

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
More to the point this might actually be a -fsanitize­dress 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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/66661] incorrect memory access in optimization with flexible array member
  2015-06-25  1:25 [Bug c/66661] New: incorrect memory access in optimization with flexible array member P at draigBrady dot com
  2015-06-25  1:26 ` [Bug c/66661] " P at draigBrady dot com
@ 2015-06-25  2:01 ` P at draigBrady dot com
  2015-06-25  7:54 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: P at draigBrady dot com @ 2015-06-25  2:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661

--- Comment #7 from Pádraig Brady <P at draigBrady dot com> ---
Created attachment 35852
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35852&action=edit
reproducer
>From gcc-bugs-return-490164-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 02:35:56 2015
Return-Path: <gcc-bugs-return-490164-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 105355 invoked by alias); 25 Jun 2015 02:35:55 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 105114 invoked by uid 48); 25 Jun 2015 02:35:51 -0000
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/66658] missing -Wunused-value negating a function result in a comma expression
Date: Thu, 25 Jun 2015 02:35: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.0
X-Bugzilla-Keywords: diagnostic, documentation
X-Bugzilla-Severity: minor
X-Bugzilla-Who: msebor 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:
Message-ID: <bug-66658-4-XdQKcW30sw@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66658-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66658-4@http.gcc.gnu.org/bugzilla/>
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/msg02496.txt.bz2
Content-length: 175

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf658

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
See also pr64639 (which this bug may be a duplicate of).


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/66661] incorrect memory access in optimization with flexible array member
  2015-06-25  1:25 [Bug c/66661] New: incorrect memory access in optimization with flexible array member P at draigBrady dot com
  2015-06-25  1:26 ` [Bug c/66661] " P at draigBrady dot com
  2015-06-25  2:01 ` [Bug middle-end/66661] " P at draigBrady dot com
@ 2015-06-25  7:54 ` rguenth at gcc dot gnu.org
  2015-06-25 11:04 ` P at draigBrady dot com
  2015-06-25 17:13 ` joseph at codesourcery dot com
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-25  7:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yes, consider

struct X { int n; char x[1]; };

which has sizeof(X) == 8 unless you use __attribute__((packed)) (in which case
alignment also gets dropped down to 1).


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/66661] incorrect memory access in optimization with flexible array member
  2015-06-25  1:25 [Bug c/66661] New: incorrect memory access in optimization with flexible array member P at draigBrady dot com
                   ` (2 preceding siblings ...)
  2015-06-25  7:54 ` rguenth at gcc dot gnu.org
@ 2015-06-25 11:04 ` P at draigBrady dot com
  2015-06-25 17:13 ` joseph at codesourcery dot com
  4 siblings, 0 replies; 6+ messages in thread
From: P at draigBrady dot com @ 2015-06-25 11:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661

--- Comment #9 from Pádraig Brady <P at draigBrady dot com> ---
I'm not understanding completely TBH. Are flexible array members not special?
Should the optimizations be restricted on access through the flexible array,
because I presume most/all existing allocation code is not considering this
alignment/padding issue. I certainly didn't notice any examples when looking
into a workaround which I came up with independently. For my reference there
are some notes RE GCC's divergence from C99 re padding and flexi arrays at:
https://sites.google.com/site/embeddedmonologue/home/c-programming/data-alig
>From gcc-bugs-return-490190-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jun 25 11:49:08 2015
Return-Path: <gcc-bugs-return-490190-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 46295 invoked by alias); 25 Jun 2015 11:49:06 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 46234 invoked by uid 48); 25 Jun 2015 11:49:02 -0000
From: "mwahab at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/64783] -march=armv8.1-a should be supported
Date: Thu, 25 Jun 2015 11:49:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mwahab at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mwahab at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-64783-4-ZwkLsxjkSd@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64783-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64783-4@http.gcc.gnu.org/bugzilla/>
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/msg02522.txt.bz2
Content-length: 1183

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd783

--- Comment #3 from mwahab at gcc dot gnu.org ---
I've just noticed this has been assigned to me. Support for -march=armv8.1-a
has been added to the Aarch64 backend, the ARM backend is still to be done.

Author: mwahab
Date: Tue Jun 16 13:38:37 2015
New Revision: 224519

URL: https://gcc.gnu.org/viewcvs?rev"4519&root=gcc&view=rev
Log:
2015-06-16  Matthew Wahab  <matthew.wahab@arm.com>

        * config/aarch64/aarch64-arches.def: Add "armv8.1-a".
        * config/aarch64/aarch64-options-extensions.def: Update "fP",
        "simd" and "crypto".  Add "lse", "pan", "lor" and "rdma".
        * gcc/config/aarch64/aarch64.h (AARCH64_FL_LSE): New.
        (AARCH64_FL_PAN): New.
        (AARCH64_FL_LOR): New.
        (AARCH64_FL_RDMA): New.
        (AARCH64_FL_FOR_ARCH8_1): New.
        * doc/invoke.texi (AArch64 Options): Add "armv8.1-a" to
        -march. Add "lse", "pan", "lor", "rdma" to feature modifiers.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/aarch64/aarch64-arches.def
    trunk/gcc/config/aarch64/aarch64-option-extensions.def
    trunk/gcc/config/aarch64/aarch64.h
    trunk/gcc/doc/invoke.texi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug middle-end/66661] incorrect memory access in optimization with flexible array member
  2015-06-25  1:25 [Bug c/66661] New: incorrect memory access in optimization with flexible array member P at draigBrady dot com
                   ` (3 preceding siblings ...)
  2015-06-25 11:04 ` P at draigBrady dot com
@ 2015-06-25 17:13 ` joseph at codesourcery dot com
  4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2015-06-25 17:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66661

--- Comment #10 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Thu, 25 Jun 2015, P at draigBrady dot com wrote:

> I'm not understanding completely TBH. Are flexible array members not special?
> Should the optimizations be restricted on access through the flexible array,
> because I presume most/all existing allocation code is not considering this
> alignment/padding issue. I certainly didn't notice any examples when looking
> into a workaround which I came up with independently. For my reference there
> are some notes RE GCC's divergence from C99 re padding and flexi arrays at:
> https://sites.google.com/site/embeddedmonologue/home/c-programming/data-alig

That page doesn't exist - I assume you mean: 
https://sites.google.com/site/embeddedmonologue/home/c-programming/data-alignment-structure-padding-and-flexible-array-member

That page is over ten years out of date - it's quoting the wording in C99 
as it was before it was corrected by TC2 (published 2004-11-15).  You 
should look at the post-TC2 wording rather than the old wording with 
various defects in it.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-25 17:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25  1:25 [Bug c/66661] New: incorrect memory access in optimization with flexible array member P at draigBrady dot com
2015-06-25  1:26 ` [Bug c/66661] " P at draigBrady dot com
2015-06-25  2:01 ` [Bug middle-end/66661] " P at draigBrady dot com
2015-06-25  7:54 ` rguenth at gcc dot gnu.org
2015-06-25 11:04 ` P at draigBrady dot com
2015-06-25 17:13 ` joseph at codesourcery dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).