This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/80533] New: Alias analysis of zero length array does not recognize accesses beyond end of array
- From: "sje at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 26 Apr 2017 19:07:20 +0000
- Subject: [Bug middle-end/80533] New: Alias analysis of zero length array does not recognize accesses beyond end of array
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80533
Bug ID: 80533
Summary: Alias analysis of zero length array does not recognize
accesses beyond end of array
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: sje at gcc dot gnu.org
Target Milestone: ---
Created attachment 41274
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41274&action=edit
Test case
GCC should treat zero length arrays like C99 flexible arrays when they are
at the end of a structure. I.e. recognize that accesses to that array may
go beyond the end of the structure. GCC has been treating zero length
arrays and flexible arrays differently since at least 5.0.
This was found on aarch64 but the bug is not platform specific. A test case
is attached, it cannot be run but if compiled for aarch64 with
-O2 -fno-strict-aliasing and either -UFLEX or -DFLEX you can see the
different code. In the -UFLEX case it generates a load/load/store/store
sequence and in the -DFLEX case it generates load/store/load/store for
the code in the main loop.
See also:
https://gcc.gnu.org/ml/gcc/2017-04/msg00118.html
https://gcc.gnu.org/ml/gcc-patches/2017-04/msg01257.html