This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/32856] Invalid optimization in the face of aliasing
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Jul 2007 12:09:25 -0000
- Subject: [Bug middle-end/32856] Invalid optimization in the face of aliasing
- References: <bug-32856-3511@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #8 from rguenth at gcc dot gnu dot org 2007-07-24 12:09 -------
You may only access union members through the union, not through other
pointers.
GCC is perfectly valid in caching n->next in the first example. So, for
comment #4, it is true that &u.a.n.next == &u.b.n.prev, but you have to do
accesses to n->next and n->prev through the _union_, otherwise the example
is not valid. So you you would need
struct node {
union u *prev;
union u *next;
};
union {
struct {
void* unused;
struct node n;
} a;
struct node b;
} u;
or another creative way of doing all accesses to ->prev and ->next through
the union type.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32856