From owner-freebsd-current@FreeBSD.ORG Sat Sep 6 02:46:35 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A050C16A4BF for ; Sat, 6 Sep 2003 02:46:35 -0700 (PDT) Received: from ns1.xcllnt.net (209-128-86-226.BAYAREA.NET [209.128.86.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0771B43FE9 for ; Sat, 6 Sep 2003 02:46:34 -0700 (PDT) (envelope-from marcel@xcllnt.net) Received: from athlon.pn.xcllnt.net (athlon.pn.xcllnt.net [192.168.4.3]) by ns1.xcllnt.net (8.12.9/8.12.9) with ESMTP id h869kFjR007934; Sat, 6 Sep 2003 02:46:15 -0700 (PDT) (envelope-from marcel@piii.pn.xcllnt.net) Received: from athlon.pn.xcllnt.net (localhost [127.0.0.1]) by athlon.pn.xcllnt.net (8.12.9/8.12.9) with ESMTP id h869kEig000594; Sat, 6 Sep 2003 02:46:14 -0700 (PDT) (envelope-from marcel@athlon.pn.xcllnt.net) Received: (from marcel@localhost) by athlon.pn.xcllnt.net (8.12.9/8.12.9/Submit) id h869kE2c000593; Sat, 6 Sep 2003 02:46:14 -0700 (PDT) (envelope-from marcel) Date: Sat, 6 Sep 2003 02:46:14 -0700 From: Marcel Moolenaar To: Alexander Leidinger Message-ID: <20030906094614.GA535@athlon.pn.xcllnt.net> References: <20030904180448.021a1b6b.Alexander@Leidinger.net> <20030904162858.GI98381@dan.emsphone.com> <20030905001411.3a9030b3.Alexander@Leidinger.net> <20030904225123.GB39916@dan.emsphone.com> <3F584B85.AAC3A11D@mindspring.com> <20030905105507.51ba3183.Alexander@Leidinger.net> <20030905165557.GB566@dhcp01.pn.xcllnt.net> <20030906103334.0f3233aa.Alexander@Leidinger.net> <20030906084259.GP16766@funkthat.com> <20030906105752.7bbed09b.Alexander@Leidinger.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030906105752.7bbed09b.Alexander@Leidinger.net> User-Agent: Mutt/1.5.4i cc: Dan Nelson cc: John-Mark Gurney cc: current@freebsd.org Subject: Re: Question about genassym, locore.s and 0-sized arrays(showstopper for an icc compiled kernel) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Sep 2003 09:46:35 -0000 On Sat, Sep 06, 2003 at 10:57:52AM +0200, Alexander Leidinger wrote: > > ---snip--- > % #include > > struct foo { > int tag; > char obj[]; > }; > > int main(void) { > struct foo bar; > > printf("%d\n", sizeof(struct foo)); > printf("%d\n", sizeof(bar)); > > return 0; > } > > % ./a.out > 4 > 4 > ---snip--- The compiler seems to behave correctly WRT C99. However, when presented with code that uses extensions the compiler behaves inconsistently or erratically. If the compiler cannot do any- thing useful with zero-sized arrays, it should reject them completely. Only then can one reasonably fall back on C99 to explain the behaviour of the compiler. However, since the compiler accepts zero-sized arrays, it is already in violation with C99 and one cannot use C99 as a basis to explain the any behaviour of the compiler in the context of the non-compliant construct. The creation of single-element array instead of the declared zero-element array is downright broken. My $0.02 -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net