From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28748 invoked by alias); 24 May 2009 13:05:38 -0000 Received: (qmail 28739 invoked by uid 22791); 24 May 2009 13:05:37 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 24 May 2009 13:05:29 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n4OD5SDZ025915; Sun, 24 May 2009 09:05:28 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n4OD5RnA031229; Sun, 24 May 2009 09:05:27 -0400 Received: from zebedee.pink (vpn-12-63.rdu.redhat.com [10.11.12.63]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n4OD5OPn009480; Sun, 24 May 2009 09:05:25 -0400 Message-ID: <4A194614.2040401@redhat.com> Date: Sun, 24 May 2009 20:57:00 -0000 From: Andrew Haley User-Agent: Thunderbird 2.0.0.17 (X11/20081009) MIME-Version: 1.0 To: Dave Korn CC: "gcc@gcc.gnu.org" Subject: Re: What does zero-length array mean at file scope? References: <4A189BCD.1090707@gmail.com> <4A18A2C8.2020204@gmail.com> <4A18B11A.6080505@gmail.com> <4A1912AC.6080505@redhat.com> <4A191A80.9010001@gmail.com> <4A1922B0.9090209@redhat.com> <4A192ADD.1060104@gmail.com> <4A192FA1.6050301@gmail.com> In-Reply-To: <4A192FA1.6050301@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00602.txt.bz2 Dave Korn wrote: > Dave Korn wrote: >> Dave Korn wrote: >>> I've read http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html about six >>> times and can't see anywhere it even hints that you can use this syntax >>> anywhere except as the trailing member of a struct. >> Andrew Haley wrote: >>> But zero-length arrays are a gcc extension. There's nothing that limits >>> them to the last member of a struct. zero-length arrays must be rejected >>> with -pedantic, but not otherwise. >>> Because it's a documented gcc extension. >> Obviously I can't see for looking; can you please point me to the precise >> chapter/page/paragraph/line that I should have found earlier? "Zero-length arrays are allowed in GNU C. They are very useful as the last element of a structure ..." That doesn't in any way imply that the last element of a struct is the only circumstance in which you may use a zero-length array. > (I honestly mean that, no sarcasm intended; it was late at night and I was > tired, I could easily have misread or overlooked something.) I did find this > comment in varasm.c:assemble_noswitch_variable() that says we need to handle > this case: > > /* Don't allocate zero bytes of common, > since that means "undefined external" in the linker. */ > if (size == 0) > rounded = 1; > > ... so I guess it counts as a backend bug if the backend still emits a zero in > the .comm directive, and that the documentation of ASM_OUTPUT.*COMMON should > probably be improved to warn of the danger that size may be zero. Yes. That's what is usually done: all you have to do is fix the back end. Andrew.