From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21565 invoked by alias); 26 Apr 2015 17:50:40 -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 21533 invoked by uid 48); 26 Apr 2015 17:50:37 -0000 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/65892] gcc fails to implement N685 aliasing of union members Date: Sun, 26 Apr 2015 17:50: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.0 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: 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-04/txt/msg02228.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65892 --- Comment #5 from Andrew Pinski --- (In reply to Martin Sebor from comment #4) > Thanks for the pointer! I had looked for a related bug report but couldn't > find it. > > There's an important difference between the test cases in pr14319 and the > one here that's easy to overlook. The rule only applies to structs defined > in unions, not those defined at file scope and only used to declare union > members, and to translation units in which the union definition is visible. No that is not the rule. If I read the section: [#5] One special guarantee is made in order to simplify the use of unions: if a union contains several structures that share a common initial sequence (see below), and if the union object currently contains one of these structures, it is permitted to inspect the common initial part of any of them anywhere that a declaration of the complete type of the union is visible. Two structures share a common initial sequence if corresponding members have compatible types (and, for bit-fields, the same widths) for a sequence of one or more initial members. --- CUT ---- I don't see anywhere the standard says about where the struct is defined in the statement above.