Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Sep 2003 02:46:14 -0700
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        Alexander Leidinger <Alexander@Leidinger.net>
Cc:        current@freebsd.org
Subject:   Re: Question about genassym, locore.s and 0-sized arrays(showstopper for  an icc compiled kernel)
Message-ID:  <20030906094614.GA535@athlon.pn.xcllnt.net>
In-Reply-To: <20030906105752.7bbed09b.Alexander@Leidinger.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>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 06, 2003 at 10:57:52AM +0200, Alexander Leidinger wrote:
> 
> ---snip---
> % <marcel.c   
> #include <stdio.h>
> 
> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030906094614.GA535>