From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10428 invoked by alias); 24 Jul 2007 12:09:34 -0000 Received: (qmail 10373 invoked by uid 48); 24 Jul 2007 12:09:25 -0000 Date: Tue, 24 Jul 2007 12:09:00 -0000 Message-ID: <20070724120925.10372.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug middle-end/32856] Invalid optimization in the face of aliasing In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" 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 X-SW-Source: 2007-07/txt/msg02442.txt.bz2 ------- 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