From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9457 invoked by alias); 2 Aug 2012 23:04:59 -0000 Received: (qmail 9449 invoked by uid 22791); 2 Aug 2012 23:04:58 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Aug 2012 23:04:46 +0000 From: "josh at joshtriplett dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/54162] New: Does not accept static global anonymous unions or structs Date: Thu, 02 Aug 2012 23:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: josh at joshtriplett dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 2012-08/txt/msg00153.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D54162 Bug #: 54162 Summary: Does not accept static global anonymous unions or structs Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: josh@joshtriplett.org C1X, and numerous other compilers, support static anonymous unions or struc= ts at file scope. For example, the following code should work with a C1X compiler: static union { unsigned x; unsigned y; }; int main(void) { x =3D 5; return y; } However, GCC says: test.c:4:1: warning: unnamed struct/union that defines no instances [enable= d by default] test.c: In function =E2=80=98main=E2=80=99: test.c:8:5: error: =E2=80=98x=E2=80=99 undeclared (first use in this functi= on) test.c:8:5: note: each undeclared identifier is reported only once for each function it appears in test.c:9:12: error: =E2=80=98y=E2=80=99 undeclared (first use in this funct= ion)